|
19 | 19 | import java.util.List;
|
20 | 20 | import java.util.function.Consumer;
|
21 | 21 |
|
22 |
| -import jakarta.servlet.http.HttpServletRequest; |
23 |
| - |
24 |
| -import org.springframework.http.HttpMethod; |
25 | 22 | import org.springframework.security.authentication.AuthenticationManager;
|
26 | 23 | import org.springframework.security.authentication.AuthenticationProvider;
|
27 | 24 | import org.springframework.security.config.annotation.ObjectPostProcessor;
|
|
45 | 42 | import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
46 | 43 | import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
|
47 | 44 | import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
48 |
| -import org.springframework.security.web.util.matcher.AntPathRequestMatcher; |
49 |
| -import org.springframework.security.web.util.matcher.OrRequestMatcher; |
50 | 45 | import org.springframework.security.web.util.matcher.RequestMatcher;
|
51 | 46 | import org.springframework.util.Assert;
|
52 | 47 | import org.springframework.util.StringUtils;
|
53 | 48 |
|
| 49 | +import jakarta.servlet.http.HttpServletRequest; |
| 50 | + |
54 | 51 | /**
|
55 | 52 | * Configurer for the OAuth 2.0 Authorization Endpoint.
|
56 | 53 | *
|
@@ -208,33 +205,26 @@ void setSessionAuthenticationStrategy(SessionAuthenticationStrategy sessionAuthe
|
208 | 205 |
|
209 | 206 | @Override
|
210 | 207 | void init(HttpSecurity httpSecurity) {
|
211 |
| - AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils.getAuthorizationServerSettings(httpSecurity); |
212 |
| - this.requestMatcher = new OrRequestMatcher( |
213 |
| - new AntPathRequestMatcher( |
214 |
| - authorizationServerSettings.getAuthorizationEndpoint(), |
215 |
| - HttpMethod.GET.name()), |
216 |
| - new AntPathRequestMatcher( |
217 |
| - authorizationServerSettings.getAuthorizationEndpoint(), |
218 |
| - HttpMethod.POST.name())); |
| 208 | + AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils |
| 209 | + .getAuthorizationServerSettings(httpSecurity); |
| 210 | + this.requestMatcher = OAuth2AuthorizationEndpointFilter |
| 211 | + .createDefaultRequestMatcher(authorizationServerSettings.getAuthorizationEndpoint()); |
219 | 212 |
|
220 | 213 | List<AuthenticationProvider> authenticationProviders = createDefaultAuthenticationProviders(httpSecurity);
|
221 | 214 | if (!this.authenticationProviders.isEmpty()) {
|
222 | 215 | authenticationProviders.addAll(0, this.authenticationProviders);
|
223 | 216 | }
|
224 | 217 | this.authenticationProvidersConsumer.accept(authenticationProviders);
|
225 |
| - authenticationProviders.forEach(authenticationProvider -> |
226 |
| - httpSecurity.authenticationProvider(postProcess(authenticationProvider))); |
| 218 | + authenticationProviders.forEach( |
| 219 | + authenticationProvider -> httpSecurity.authenticationProvider(postProcess(authenticationProvider))); |
227 | 220 | }
|
228 | 221 |
|
229 | 222 | @Override
|
230 | 223 | void configure(HttpSecurity httpSecurity) {
|
231 | 224 | AuthenticationManager authenticationManager = httpSecurity.getSharedObject(AuthenticationManager.class);
|
232 |
| - AuthorizationServerSettings authorizationServerSettings = OAuth2ConfigurerUtils.getAuthorizationServerSettings(httpSecurity); |
233 | 225 |
|
234 |
| - OAuth2AuthorizationEndpointFilter authorizationEndpointFilter = |
235 |
| - new OAuth2AuthorizationEndpointFilter( |
236 |
| - authenticationManager, |
237 |
| - authorizationServerSettings.getAuthorizationEndpoint()); |
| 226 | + OAuth2AuthorizationEndpointFilter authorizationEndpointFilter = new OAuth2AuthorizationEndpointFilter( |
| 227 | + authenticationManager, getRequestMatcher()); |
238 | 228 | List<AuthenticationConverter> authenticationConverters = createDefaultAuthenticationConverters();
|
239 | 229 | if (!this.authorizationRequestConverters.isEmpty()) {
|
240 | 230 | authenticationConverters.addAll(0, this.authorizationRequestConverters);
|
|
0 commit comments