Spring 非法状态例外:Can';在任何请求之后都不能配置antMatchers
我想将Spring云安全OAuth2配置为应用不同的权限:Spring 非法状态例外:Can';在任何请求之后都不能配置antMatchers,spring,spring-boot,spring-security,spring-security-oauth2,Spring,Spring Boot,Spring Security,Spring Security Oauth2,我想将Spring云安全OAuth2配置为应用不同的权限: /oauth/token-应应用httpBasic /oauth/revoke-不应应用httpBasic 我试过这个: http .csrf() .disable() .authorizeRequests() .anyRequest().authenticated() .and(
/oauth/token
-应应用httpBasic
/oauth/revoke
-不应应用httpBasic
我试过这个:
http
.csrf()
.disable()
.authorizeRequests()
.anyRequest().authenticated()
.and()
// Configure token authentication permissions
.requestMatchers().antMatchers(HttpMethod.POST,"/oauth/token")
.and()
// Configure token revoke permissions
.authorizeRequests().antMatchers(HttpMethod.POST,"/oauth/revoke").permitAll()
.and()
.httpBasic()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
当我运行代码时,我得到一个错误:
原因:org.springframework.beans.beans实例化异常:未能实例化[javax.servlet.Filter]:工厂方法“springSecurityFilterChain”引发异常;嵌套异常为java.lang.IllegalStateException:无法在任何请求后配置antMatchers
您知道如何正确应用此配置吗?“无法在任何请求之后配置antMatchers”
您好,请尝试将antMatchers放在任何请求之前我收到“错误描述”:“访问此资源需要完全身份验证”`