spring security permitAll still considering token passed in Authorization header and returns 401 if token is invalid

后端 未结 2 659
说谎
说谎 2020-12-18 19:02

I am using spring security oauth in my project. I am excluding some urls from authentication by configuring in spring security ResourceServerConfigurerAdapter. I added

2条回答
  •  庸人自扰
    2020-12-18 19:35

    As per spring-oauth2 docs https://projects.spring.io/spring-security-oauth/docs/oauth2.html

    Note: if your Authorization Server is also a Resource Server then there is another security filter chain with lower priority controlling the API resources. Fo those requests to be protected by access tokens you need their paths not to be matched by the ones in the main user-facing filter chain, so be sure to include a request matcher that picks out only non-API resources in the WebSecurityConfigurer above.

    So define WebSecurityConfigurer implementation with higher order than ResourceServerConfig.

提交回复
热议问题