diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerConfigurer.java b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerConfigurer.java index e39ff4a86f..8afee07b66 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerConfigurer.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2AuthorizationServerConfigurer.java @@ -396,8 +396,6 @@ public final class OAuth2AuthorizationServerConfigurer new OrRequestMatcher(preferredMatchers)); } - httpSecurity.securityMatchers((securityMatchers) -> securityMatchers.requestMatchers(this.endpointsMatcher)); - httpSecurity.csrf((csrf) -> csrf.ignoringRequestMatchers(this.endpointsMatcher)); if (getConfigurer(OAuth2ClientRegistrationEndpointConfigurer.class) != null) { diff --git a/docs/modules/ROOT/pages/servlet/oauth2/authorization-server/getting-started.adoc b/docs/modules/ROOT/pages/servlet/oauth2/authorization-server/getting-started.adoc index d0f22cef75..dacff440a3 100644 --- a/docs/modules/ROOT/pages/servlet/oauth2/authorization-server/getting-started.adoc +++ b/docs/modules/ROOT/pages/servlet/oauth2/authorization-server/getting-started.adoc @@ -132,10 +132,11 @@ public class SecurityConfig { // @formatter:off http - .oauth2AuthorizationServer((authorizationServer) -> + .oauth2AuthorizationServer((authorizationServer) -> { + http.securityMatcher(authorizationServer.getEndpointsMatcher()); authorizationServer - .oidc(Customizer.withDefaults()) // Enable OpenID Connect 1.0 - ) + .oidc(Customizer.withDefaults()); // Enable OpenID Connect 1.0 + }) .authorizeHttpRequests((authorize) -> authorize .anyRequest().authenticated()