mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-30 16:52:13 +00:00
Polish gh-12438
This commit is contained in:
parent
919280b3e4
commit
e139f1c2ba
@ -3829,33 +3829,13 @@ public class ServerHttpSecurity {
|
|||||||
|
|
||||||
private ServerAuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository;
|
private ServerAuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository;
|
||||||
|
|
||||||
private ServerRedirectStrategy authorizationRedirectStrategy;
|
|
||||||
|
|
||||||
private ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver;
|
private ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver;
|
||||||
|
|
||||||
|
private ServerRedirectStrategy authorizationRedirectStrategy;
|
||||||
|
|
||||||
private OAuth2ClientSpec() {
|
private OAuth2ClientSpec() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the resolver used for resolving {@link OAuth2AuthorizationRequest}'s.
|
|
||||||
* @param authorizationRequestResolver the resolver used for resolving
|
|
||||||
* {@link OAuth2AuthorizationRequest}'s
|
|
||||||
* @return the {@link OAuth2ClientSpec} for further configuration
|
|
||||||
* @since 6.1
|
|
||||||
*/
|
|
||||||
public OAuth2ClientSpec authorizationRequestResolver(
|
|
||||||
ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver) {
|
|
||||||
this.authorizationRequestResolver = authorizationRequestResolver;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private OAuth2AuthorizationRequestRedirectWebFilter getRedirectWebFilter() {
|
|
||||||
if (this.authorizationRequestResolver != null) {
|
|
||||||
return new OAuth2AuthorizationRequestRedirectWebFilter(this.authorizationRequestResolver);
|
|
||||||
}
|
|
||||||
return new OAuth2AuthorizationRequestRedirectWebFilter(getClientRegistrationRepository());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the converter to use
|
* Sets the converter to use
|
||||||
* @param authenticationConverter the converter to use
|
* @param authenticationConverter the converter to use
|
||||||
@ -3945,6 +3925,26 @@ public class ServerHttpSecurity {
|
|||||||
return this.authorizationRequestRepository;
|
return this.authorizationRequestRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the resolver used for resolving {@link OAuth2AuthorizationRequest}'s.
|
||||||
|
* @param authorizationRequestResolver the resolver used for resolving
|
||||||
|
* {@link OAuth2AuthorizationRequest}'s
|
||||||
|
* @return the {@link OAuth2ClientSpec} to customize
|
||||||
|
* @since 6.1
|
||||||
|
*/
|
||||||
|
public OAuth2ClientSpec authorizationRequestResolver(
|
||||||
|
ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver) {
|
||||||
|
this.authorizationRequestResolver = authorizationRequestResolver;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private OAuth2AuthorizationRequestRedirectWebFilter getRedirectWebFilter() {
|
||||||
|
if (this.authorizationRequestResolver != null) {
|
||||||
|
return new OAuth2AuthorizationRequestRedirectWebFilter(this.authorizationRequestResolver);
|
||||||
|
}
|
||||||
|
return new OAuth2AuthorizationRequestRedirectWebFilter(getClientRegistrationRepository());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the redirect strategy for Authorization Endpoint redirect URI.
|
* Sets the redirect strategy for Authorization Endpoint redirect URI.
|
||||||
* @param authorizationRedirectStrategy the redirect strategy
|
* @param authorizationRedirectStrategy the redirect strategy
|
||||||
@ -3971,7 +3971,6 @@ public class ServerHttpSecurity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void configure(ServerHttpSecurity http) {
|
protected void configure(ServerHttpSecurity http) {
|
||||||
ReactiveClientRegistrationRepository clientRegistrationRepository = getClientRegistrationRepository();
|
|
||||||
ServerOAuth2AuthorizedClientRepository authorizedClientRepository = getAuthorizedClientRepository();
|
ServerOAuth2AuthorizedClientRepository authorizedClientRepository = getAuthorizedClientRepository();
|
||||||
ServerAuthenticationConverter authenticationConverter = getAuthenticationConverter();
|
ServerAuthenticationConverter authenticationConverter = getAuthenticationConverter();
|
||||||
ReactiveAuthenticationManager authenticationManager = getAuthenticationManager();
|
ReactiveAuthenticationManager authenticationManager = getAuthenticationManager();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -39,8 +39,8 @@ import org.springframework.security.oauth2.client.registration.InMemoryReactiveC
|
|||||||
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
|
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
|
||||||
import org.springframework.security.oauth2.client.registration.TestClientRegistrations;
|
import org.springframework.security.oauth2.client.registration.TestClientRegistrations;
|
||||||
import org.springframework.security.oauth2.client.web.server.ServerAuthorizationRequestRepository;
|
import org.springframework.security.oauth2.client.web.server.ServerAuthorizationRequestRepository;
|
||||||
import org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizedClientRepository;
|
|
||||||
import org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizationRequestResolver;
|
import org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizationRequestResolver;
|
||||||
|
import org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizedClientRepository;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AccessToken;
|
import org.springframework.security.oauth2.core.OAuth2AccessToken;
|
||||||
import org.springframework.security.oauth2.core.TestOAuth2AccessTokens;
|
import org.springframework.security.oauth2.core.TestOAuth2AccessTokens;
|
||||||
import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationExchange;
|
import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationExchange;
|
||||||
@ -134,8 +134,8 @@ public class OAuth2ClientSpecTests {
|
|||||||
ServerAuthenticationConverter converter = config.authenticationConverter;
|
ServerAuthenticationConverter converter = config.authenticationConverter;
|
||||||
ReactiveAuthenticationManager manager = config.manager;
|
ReactiveAuthenticationManager manager = config.manager;
|
||||||
ServerAuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository = config.authorizationRequestRepository;
|
ServerAuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository = config.authorizationRequestRepository;
|
||||||
ServerRequestCache requestCache = config.requestCache;
|
|
||||||
ServerOAuth2AuthorizationRequestResolver resolver = config.resolver;
|
ServerOAuth2AuthorizationRequestResolver resolver = config.resolver;
|
||||||
|
ServerRequestCache requestCache = config.requestCache;
|
||||||
OAuth2AuthorizationRequest authorizationRequest = TestOAuth2AuthorizationRequests.request()
|
OAuth2AuthorizationRequest authorizationRequest = TestOAuth2AuthorizationRequests.request()
|
||||||
.redirectUri("/authorize/oauth2/code/registration-id").build();
|
.redirectUri("/authorize/oauth2/code/registration-id").build();
|
||||||
OAuth2AuthorizationResponse authorizationResponse = TestOAuth2AuthorizationResponses.success()
|
OAuth2AuthorizationResponse authorizationResponse = TestOAuth2AuthorizationResponses.success()
|
||||||
@ -268,10 +268,10 @@ public class OAuth2ClientSpecTests {
|
|||||||
ServerAuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository = mock(
|
ServerAuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository = mock(
|
||||||
ServerAuthorizationRequestRepository.class);
|
ServerAuthorizationRequestRepository.class);
|
||||||
|
|
||||||
ServerRequestCache requestCache = mock(ServerRequestCache.class);
|
|
||||||
|
|
||||||
ServerOAuth2AuthorizationRequestResolver resolver = mock(ServerOAuth2AuthorizationRequestResolver.class);
|
ServerOAuth2AuthorizationRequestResolver resolver = mock(ServerOAuth2AuthorizationRequestResolver.class);
|
||||||
|
|
||||||
|
ServerRequestCache requestCache = mock(ServerRequestCache.class);
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
@ -39,6 +39,7 @@ public class OAuth2ClientSecurityConfig {
|
|||||||
.clientRegistrationRepository(this.clientRegistrationRepository())
|
.clientRegistrationRepository(this.clientRegistrationRepository())
|
||||||
.authorizedClientRepository(this.authorizedClientRepository())
|
.authorizedClientRepository(this.authorizedClientRepository())
|
||||||
.authorizationRequestRepository(this.authorizationRequestRepository())
|
.authorizationRequestRepository(this.authorizationRequestRepository())
|
||||||
|
.authorizationRequestResolver(this.authorizationRequestResolver())
|
||||||
.authenticationConverter(this.authenticationConverter())
|
.authenticationConverter(this.authenticationConverter())
|
||||||
.authenticationManager(this.authenticationManager())
|
.authenticationManager(this.authenticationManager())
|
||||||
);
|
);
|
||||||
@ -62,6 +63,7 @@ class OAuth2ClientSecurityConfig {
|
|||||||
clientRegistrationRepository = clientRegistrationRepository()
|
clientRegistrationRepository = clientRegistrationRepository()
|
||||||
authorizedClientRepository = authorizedClientRepository()
|
authorizedClientRepository = authorizedClientRepository()
|
||||||
authorizationRequestRepository = authorizedRequestRepository()
|
authorizationRequestRepository = authorizedRequestRepository()
|
||||||
|
authorizationRequestResolver = authorizationRequestResolver()
|
||||||
authenticationConverter = authenticationConverter()
|
authenticationConverter = authenticationConverter()
|
||||||
authenticationManager = authenticationManager()
|
authenticationManager = authenticationManager()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user