Rename AuthorizationCodeAuthenticationFilter -> OAuth2LoginAuthenticationFilter
Fixes gh-4686
This commit is contained in:
-1
@@ -60,7 +60,6 @@ import java.util.Map;
|
||||
* @see AuthorizationRequestUriBuilder
|
||||
* @see ClientRegistration
|
||||
* @see ClientRegistrationRepository
|
||||
* @see AuthorizationCodeAuthenticationFilter
|
||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.1">Section 4.1 Authorization Code Grant</a>
|
||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.1.1">Section 4.1.1 Authorization Request (Authorization Code)</a>
|
||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.2">Section 4.2 Implicit Grant</a>
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
* <p>
|
||||
* Used by the {@link AuthorizationRequestRedirectFilter} for persisting the <i>Authorization Request</i>
|
||||
* before it initiates the authorization code grant flow.
|
||||
* As well, used by the {@link AuthorizationCodeAuthenticationFilter} for resolving
|
||||
* As well, used by the {@link OAuth2LoginAuthenticationFilter} for resolving
|
||||
* the associated <i>Authorization Request</i> when handling the <i>Authorization Response</i>.
|
||||
*
|
||||
* @author Joe Grandja
|
||||
|
||||
+3
-8
@@ -73,17 +73,17 @@ import java.io.IOException;
|
||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.1">Section 4.1 Authorization Code Grant</a>
|
||||
* @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-4.1.2">Section 4.1.2 Authorization Response</a>
|
||||
*/
|
||||
public class AuthorizationCodeAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
|
||||
public class OAuth2LoginAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
|
||||
public static final String DEFAULT_AUTHORIZATION_RESPONSE_BASE_URI = "/oauth2/authorize/code/*";
|
||||
private static final String AUTHORIZATION_REQUEST_NOT_FOUND_ERROR_CODE = "authorization_request_not_found";
|
||||
private ClientRegistrationRepository clientRegistrationRepository;
|
||||
private AuthorizationRequestRepository authorizationRequestRepository = new HttpSessionAuthorizationRequestRepository();
|
||||
|
||||
public AuthorizationCodeAuthenticationFilter() {
|
||||
public OAuth2LoginAuthenticationFilter() {
|
||||
this(DEFAULT_AUTHORIZATION_RESPONSE_BASE_URI);
|
||||
}
|
||||
|
||||
public AuthorizationCodeAuthenticationFilter(String authorizationResponseBaseUri) {
|
||||
public OAuth2LoginAuthenticationFilter(String authorizationResponseBaseUri) {
|
||||
super(authorizationResponseBaseUri);
|
||||
}
|
||||
|
||||
@@ -134,11 +134,6 @@ public class AuthorizationCodeAuthenticationFilter extends AbstractAuthenticatio
|
||||
return this.getAuthenticationManager().authenticate(clientAuthentication);
|
||||
}
|
||||
|
||||
public final void setAuthorizationResponseBaseUri(String authorizationResponseBaseUri) {
|
||||
Assert.hasText(authorizationResponseBaseUri, "authorizationResponseBaseUri cannot be empty");
|
||||
this.setFilterProcessesUrl(authorizationResponseBaseUri);
|
||||
}
|
||||
|
||||
public final void setClientRegistrationRepository(ClientRegistrationRepository clientRegistrationRepository) {
|
||||
Assert.notNull(clientRegistrationRepository, "clientRegistrationRepository cannot be null");
|
||||
this.clientRegistrationRepository = clientRegistrationRepository;
|
||||
+10
-10
@@ -49,17 +49,17 @@ import java.util.Map;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests {@link AuthorizationCodeAuthenticationFilter}.
|
||||
* Tests {@link OAuth2LoginAuthenticationFilter}.
|
||||
*
|
||||
* @author Joe Grandja
|
||||
*/
|
||||
public class AuthorizationCodeAuthenticationFilterTests {
|
||||
public class OAuth2LoginAuthenticationFilterTests {
|
||||
|
||||
@Test
|
||||
public void doFilterWhenNotAuthorizationCodeResponseThenContinueChain() throws Exception {
|
||||
ClientRegistration clientRegistration = TestUtil.googleClientRegistration();
|
||||
|
||||
AuthorizationCodeAuthenticationFilter filter = Mockito.spy(setupFilter(clientRegistration));
|
||||
OAuth2LoginAuthenticationFilter filter = Mockito.spy(setupFilter(clientRegistration));
|
||||
|
||||
String requestURI = "/path";
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestURI);
|
||||
@@ -77,7 +77,7 @@ public class AuthorizationCodeAuthenticationFilterTests {
|
||||
public void doFilterWhenAuthorizationCodeErrorResponseThenAuthenticationFailureHandlerIsCalled() throws Exception {
|
||||
ClientRegistration clientRegistration = TestUtil.githubClientRegistration();
|
||||
|
||||
AuthorizationCodeAuthenticationFilter filter = Mockito.spy(setupFilter(clientRegistration));
|
||||
OAuth2LoginAuthenticationFilter filter = Mockito.spy(setupFilter(clientRegistration));
|
||||
AuthenticationFailureHandler failureHandler = mock(AuthenticationFailureHandler.class);
|
||||
filter.setAuthenticationFailureHandler(failureHandler);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class AuthorizationCodeAuthenticationFilterTests {
|
||||
AuthenticationManager authenticationManager = mock(AuthenticationManager.class);
|
||||
Mockito.when(authenticationManager.authenticate(Matchers.any(Authentication.class))).thenReturn(clientAuthentication);
|
||||
|
||||
AuthorizationCodeAuthenticationFilter filter = Mockito.spy(setupFilter(authenticationManager, clientRegistration));
|
||||
OAuth2LoginAuthenticationFilter filter = Mockito.spy(setupFilter(authenticationManager, clientRegistration));
|
||||
AuthenticationSuccessHandler successHandler = mock(AuthenticationSuccessHandler.class);
|
||||
filter.setAuthenticationSuccessHandler(successHandler);
|
||||
AuthorizationRequestRepository authorizationRequestRepository = new HttpSessionAuthorizationRequestRepository();
|
||||
@@ -135,7 +135,7 @@ public class AuthorizationCodeAuthenticationFilterTests {
|
||||
public void doFilterWhenAuthorizationCodeSuccessResponseAndNoMatchingAuthorizationRequestThenThrowOAuth2AuthenticationExceptionAuthorizationRequestNotFound() throws Exception {
|
||||
ClientRegistration clientRegistration = TestUtil.githubClientRegistration();
|
||||
|
||||
AuthorizationCodeAuthenticationFilter filter = Mockito.spy(setupFilter(clientRegistration));
|
||||
OAuth2LoginAuthenticationFilter filter = Mockito.spy(setupFilter(clientRegistration));
|
||||
AuthenticationFailureHandler failureHandler = mock(AuthenticationFailureHandler.class);
|
||||
filter.setAuthenticationFailureHandler(failureHandler);
|
||||
|
||||
@@ -152,7 +152,7 @@ public class AuthorizationCodeAuthenticationFilterTests {
|
||||
verifyThrowsOAuth2AuthenticationExceptionWithErrorCode(filter, failureHandler, "authorization_request_not_found");
|
||||
}
|
||||
|
||||
private void verifyThrowsOAuth2AuthenticationExceptionWithErrorCode(AuthorizationCodeAuthenticationFilter filter,
|
||||
private void verifyThrowsOAuth2AuthenticationExceptionWithErrorCode(OAuth2LoginAuthenticationFilter filter,
|
||||
AuthenticationFailureHandler failureHandler,
|
||||
String errorCode) throws Exception {
|
||||
|
||||
@@ -169,18 +169,18 @@ public class AuthorizationCodeAuthenticationFilterTests {
|
||||
Assertions.assertThat(oauth2AuthenticationException.getError().getErrorCode()).isEqualTo(errorCode);
|
||||
}
|
||||
|
||||
private AuthorizationCodeAuthenticationFilter setupFilter(ClientRegistration... clientRegistrations) throws Exception {
|
||||
private OAuth2LoginAuthenticationFilter setupFilter(ClientRegistration... clientRegistrations) throws Exception {
|
||||
AuthenticationManager authenticationManager = mock(AuthenticationManager.class);
|
||||
|
||||
return setupFilter(authenticationManager, clientRegistrations);
|
||||
}
|
||||
|
||||
private AuthorizationCodeAuthenticationFilter setupFilter(
|
||||
private OAuth2LoginAuthenticationFilter setupFilter(
|
||||
AuthenticationManager authenticationManager, ClientRegistration... clientRegistrations) throws Exception {
|
||||
|
||||
ClientRegistrationRepository clientRegistrationRepository = TestUtil.clientRegistrationRepository(clientRegistrations);
|
||||
|
||||
AuthorizationCodeAuthenticationFilter filter = new AuthorizationCodeAuthenticationFilter();
|
||||
OAuth2LoginAuthenticationFilter filter = new OAuth2LoginAuthenticationFilter();
|
||||
filter.setClientRegistrationRepository(clientRegistrationRepository);
|
||||
filter.setAuthenticationManager(authenticationManager);
|
||||
|
||||
Reference in New Issue
Block a user