Rename AuthorizationCodeAuthenticationProvider -> OAuth2LoginAuthenticationProvider

Fixes gh-4690
This commit is contained in:
Joe Grandja 2017-10-24 15:21:15 -04:00
parent 049080290e
commit 4dbbcabacf
4 changed files with 12 additions and 12 deletions

View File

@ -20,7 +20,7 @@ import org.springframework.core.ResolvableType;
import org.springframework.security.config.annotation.web.HttpSecurityBuilder; import org.springframework.security.config.annotation.web.HttpSecurityBuilder;
import org.springframework.security.config.annotation.web.configurers.AbstractAuthenticationFilterConfigurer; import org.springframework.security.config.annotation.web.configurers.AbstractAuthenticationFilterConfigurer;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper; import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.oauth2.client.authentication.AuthorizationCodeAuthenticationProvider; import org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationProvider;
import org.springframework.security.oauth2.client.authentication.AuthorizationCodeAuthenticationToken; import org.springframework.security.oauth2.client.authentication.AuthorizationCodeAuthenticationToken;
import org.springframework.security.oauth2.client.authentication.AuthorizationGrantTokenExchanger; import org.springframework.security.oauth2.client.authentication.AuthorizationGrantTokenExchanger;
import org.springframework.security.oauth2.client.authentication.NimbusAuthorizationCodeTokenExchanger; import org.springframework.security.oauth2.client.authentication.NimbusAuthorizationCodeTokenExchanger;
@ -247,17 +247,17 @@ public final class OAuth2LoginConfigurer<B extends HttpSecurityBuilder<B>> exten
jwtDecoderRegistry = new NimbusJwtDecoderRegistry(); jwtDecoderRegistry = new NimbusJwtDecoderRegistry();
} }
AuthorizationCodeAuthenticationProvider oauth2AuthorizationCodeAuthenticationProvider = OAuth2LoginAuthenticationProvider oauth2LoginAuthenticationProvider =
new AuthorizationCodeAuthenticationProvider(authorizationCodeTokenExchanger, oauth2UserService); new OAuth2LoginAuthenticationProvider(authorizationCodeTokenExchanger, oauth2UserService);
if (this.tokenEndpointConfig.accessTokenRepository != null) { if (this.tokenEndpointConfig.accessTokenRepository != null) {
oauth2AuthorizationCodeAuthenticationProvider.setAccessTokenRepository( oauth2LoginAuthenticationProvider.setAccessTokenRepository(
this.tokenEndpointConfig.accessTokenRepository); this.tokenEndpointConfig.accessTokenRepository);
} }
if (this.userInfoEndpointConfig.userAuthoritiesMapper != null) { if (this.userInfoEndpointConfig.userAuthoritiesMapper != null) {
oauth2AuthorizationCodeAuthenticationProvider.setAuthoritiesMapper( oauth2LoginAuthenticationProvider.setAuthoritiesMapper(
this.userInfoEndpointConfig.userAuthoritiesMapper); this.userInfoEndpointConfig.userAuthoritiesMapper);
} }
http.authenticationProvider(this.postProcess(oauth2AuthorizationCodeAuthenticationProvider)); http.authenticationProvider(this.postProcess(oauth2LoginAuthenticationProvider));
OAuth2UserService oidcUserService = this.userInfoEndpointConfig.userService; OAuth2UserService oidcUserService = this.userInfoEndpointConfig.userService;
if (oidcUserService == null) { if (oidcUserService == null) {

View File

@ -58,7 +58,7 @@ import java.util.Collection;
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.1.3">Section 4.1.3 Access Token Request</a> * @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.1.3">Section 4.1.3 Access Token Request</a>
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.1.4">Section 4.1.4 Access Token Response</a> * @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.1.4">Section 4.1.4 Access Token Response</a>
*/ */
public class AuthorizationCodeAuthenticationProvider implements AuthenticationProvider { public class OAuth2LoginAuthenticationProvider implements AuthenticationProvider {
private static final String INVALID_STATE_PARAMETER_ERROR_CODE = "invalid_state_parameter"; private static final String INVALID_STATE_PARAMETER_ERROR_CODE = "invalid_state_parameter";
private static final String INVALID_REDIRECT_URI_PARAMETER_ERROR_CODE = "invalid_redirect_uri_parameter"; private static final String INVALID_REDIRECT_URI_PARAMETER_ERROR_CODE = "invalid_redirect_uri_parameter";
private final AuthorizationGrantTokenExchanger<AuthorizationCodeAuthenticationToken> authorizationCodeTokenExchanger; private final AuthorizationGrantTokenExchanger<AuthorizationCodeAuthenticationToken> authorizationCodeTokenExchanger;
@ -66,7 +66,7 @@ public class AuthorizationCodeAuthenticationProvider implements AuthenticationPr
private SecurityTokenRepository<AccessToken> accessTokenRepository = new InMemoryAccessTokenRepository(); private SecurityTokenRepository<AccessToken> accessTokenRepository = new InMemoryAccessTokenRepository();
private GrantedAuthoritiesMapper authoritiesMapper = (authorities -> authorities); private GrantedAuthoritiesMapper authoritiesMapper = (authorities -> authorities);
public AuthorizationCodeAuthenticationProvider( public OAuth2LoginAuthenticationProvider(
AuthorizationGrantTokenExchanger<AuthorizationCodeAuthenticationToken> authorizationCodeTokenExchanger, AuthorizationGrantTokenExchanger<AuthorizationCodeAuthenticationToken> authorizationCodeTokenExchanger,
OAuth2UserService userService) { OAuth2UserService userService) {

View File

@ -18,7 +18,7 @@ package org.springframework.security.oauth2.client.web;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.AuthenticationException;
import org.springframework.security.oauth2.client.authentication.AuthorizationCodeAuthenticationProvider; import org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationProvider;
import org.springframework.security.oauth2.client.authentication.AuthorizationCodeAuthenticationToken; import org.springframework.security.oauth2.client.authentication.AuthorizationCodeAuthenticationToken;
import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationException; import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationException;
import org.springframework.security.oauth2.client.registration.ClientRegistration; import org.springframework.security.oauth2.client.registration.ClientRegistration;
@ -55,7 +55,7 @@ import java.io.IOException;
* <li> * <li>
* This <code>Filter</code> will then create an {@link AuthorizationCodeAuthenticationToken} with * This <code>Filter</code> will then create an {@link AuthorizationCodeAuthenticationToken} with
* the {@link OAuth2Parameter#CODE} received in the previous step and delegate it to * the {@link OAuth2Parameter#CODE} received in the previous step and delegate it to
* {@link AuthorizationCodeAuthenticationProvider#authenticate(Authentication)} (indirectly via {@link AuthenticationManager}). * {@link OAuth2LoginAuthenticationProvider#authenticate(Authentication)} (indirectly via {@link AuthenticationManager}).
* </li> * </li>
* </ul> * </ul>
* *
@ -63,7 +63,7 @@ import java.io.IOException;
* @since 5.0 * @since 5.0
* @see AbstractAuthenticationProcessingFilter * @see AbstractAuthenticationProcessingFilter
* @see AuthorizationCodeAuthenticationToken * @see AuthorizationCodeAuthenticationToken
* @see AuthorizationCodeAuthenticationProvider * @see OAuth2LoginAuthenticationProvider
* @see AuthorizationResponse * @see AuthorizationResponse
* @see AuthorizationRequest * @see AuthorizationRequest
* @see AuthorizationRequestRepository * @see AuthorizationRequestRepository

View File

@ -102,7 +102,7 @@ public class OidcAuthorizationCodeAuthenticationProvider implements Authenticati
if (!authorizationCodeAuthentication.getAuthorizationExchange() if (!authorizationCodeAuthentication.getAuthorizationExchange()
.getAuthorizationRequest().getScopes().contains(OidcScope.OPENID)) { .getAuthorizationRequest().getScopes().contains(OidcScope.OPENID)) {
// This is NOT an OpenID Connect Authentication Request so return null // This is NOT an OpenID Connect Authentication Request so return null
// and let AuthorizationCodeAuthenticationProvider handle it instead // and let OAuth2LoginAuthenticationProvider handle it instead
return null; return null;
} }