How to allow “/api/**” through my basic auth config and into my oauth config in Spring Security

前端 未结 2 902
忘掉有多难
忘掉有多难 2020-12-21 17:52

I have an app that uses both Basic Auth and OAuth2.

Some URLs are authorized using Basic Auth and \"/api/**\" is authorized using OAuth2.

Currently, I have t

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-21 18:44

    You should use Order(...) annotation on @Configuration classes. Make your OAuth2ServerConfig config first and serving only http.requestMatchers().antMatchers("/api/**") and make your WebSecurityConfig second (@Order(2)) without http.requestMatchers() to serve all rest URLs!

    See details on https://stackoverflow.com/a/44871933/173149

提交回复
热议问题