-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Document the need to provide a SecurityWebFilterChain or WebSecurityConfigurerAdapter when using multiple OAuth 2 security components #18507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the sample @philsttr. This is indeed caused due to the fact that |
Thanks for taking a look at this @mbhave ! |
As we add auto-configuration for more of Spring Security's features, I think we may have to accept that a certain amount of user configuration is required to use those pieces in combination. In this case, that would be a user-provided SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated());
http.oauth2ResourceServer(OAuth2ResourceServerSpec::opaqueToken);
return http.build();
} SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange().anyExchange().authenticated();
http.oauth2Login();
http.oauth2Client();
return http.build();
} The only alternative that I've been able to think of thus far is a contribution model for creating the I'll keep giving this some thought, but I'm leaning towards documenting the need for a user-provided |
We've decided that this is best addressed with documentation. The behaviour of the reactive auto-configuration is now aligned with the equivalent servlet auto-configuration where, for example, only one of |
get bug when use client and resource together. - spring-projects/spring-boot#18507
get bug when use client and resource together. - spring-projects/spring-boot#18507 set-up cors
When I recently upgraded an application from spring boot 2.2.0.M6 to 2.2.0.RC1 that uses both OAuth2 Resource Server (opaque token support) and OAuth2 Client, I found that the OAuth2 Resource Server opaque token auto configuration is no longer applied. So this appears to be a change/regression from 2.2.0.M6 -> 2.2.0.RC1
In 2.2.0.M6, I see the following in the autoconfiguration report, indicating a successful configuration of the opaque token support:
In 2.2.0.RC1, I see the following in the autoconfiguration report:
It appears that when the OAuth2 Client AutoConfiguration executes, it defines a SecurityWebFilterChain, which prevents the ReactiveOAuth2ResourceServerOpaqueTokenConfiguration.WebSecurityConfiguration from applying.
If I remove the OAuth2 Client configuration properties, the Resource Server is configured properly.
Here is an example project with a unit test that shows the behavior. The test fails when using 2.2.0.RC1, but if you change the spring boot version to 2.2.0.M6, the test will pass.
The text was updated successfully, but these errors were encountered: