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

大兔子大兔子 提交于 2019-11-29 17:04:25

You can use NegatedRequestMatcher:

A RequestMatcher that will negate the RequestMatcher passed in. For example, if the RequestMatcher passed in returns true, NegatedRequestMatcher will return false. If the RequestMatcher passed in returns false, NegatedRequestMatcher will return true.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!