我知道已经有很多问题等于......但没有任何效果,我会发疯。
我已经在 Spring 项目中实现了 JWT 身份验证,我的安全配置器在这里:
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.csrf().disable()
.authorizeRequests()
.antMatchers("/auth/**").permitAll()
.anyRequest().authenticated()
.and()
.exceptionHandling()
.authenticationEntryPoint(unauthorizedHandler)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
httpSecurity
.addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);
httpSecurity
.headers().cacheControl();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/auth/**");
}
但是所有路径都需要令牌......我已经尝试在我的控制器类中使用 @Secured("permitAll")
但也不起作用。