Change constructor param order in oauth2 client filters

Fixes gh-4818
This commit is contained in:
Joe Grandja 2017-11-12 14:58:31 -05:00
parent 1b70efce2b
commit 872a8f3189
6 changed files with 15 additions and 15 deletions

View File

@ -48,7 +48,7 @@ public final class ImplicitGrantConfigurer<B extends HttpSecurityBuilder<B>> ext
@Override @Override
public void configure(B http) throws Exception { public void configure(B http) throws Exception {
OAuth2AuthorizationRequestRedirectFilter authorizationRequestFilter = new OAuth2AuthorizationRequestRedirectFilter( OAuth2AuthorizationRequestRedirectFilter authorizationRequestFilter = new OAuth2AuthorizationRequestRedirectFilter(
this.getAuthorizationRequestBaseUri(), this.getClientRegistrationRepository()); this.getClientRegistrationRepository(), this.getAuthorizationRequestBaseUri());
http.addFilter(this.postProcess(authorizationRequestFilter)); http.addFilter(this.postProcess(authorizationRequestFilter));
} }

View File

@ -218,9 +218,9 @@ public final class OAuth2LoginConfigurer<B extends HttpSecurityBuilder<B>> exten
public void init(B http) throws Exception { public void init(B http) throws Exception {
OAuth2LoginAuthenticationFilter authenticationFilter = OAuth2LoginAuthenticationFilter authenticationFilter =
new OAuth2LoginAuthenticationFilter( new OAuth2LoginAuthenticationFilter(
OAuth2LoginAuthenticationFilter.DEFAULT_FILTER_PROCESSES_URI,
this.getClientRegistrationRepository(), this.getClientRegistrationRepository(),
this.getAuthorizedClientService()); this.getAuthorizedClientService(),
OAuth2LoginAuthenticationFilter.DEFAULT_FILTER_PROCESSES_URI);
this.setAuthenticationFilter(authenticationFilter); this.setAuthenticationFilter(authenticationFilter);
this.loginProcessingUrl(OAuth2LoginAuthenticationFilter.DEFAULT_FILTER_PROCESSES_URI); this.loginProcessingUrl(OAuth2LoginAuthenticationFilter.DEFAULT_FILTER_PROCESSES_URI);
if (this.loginPage != null) { if (this.loginPage != null) {
@ -285,7 +285,7 @@ public final class OAuth2LoginConfigurer<B extends HttpSecurityBuilder<B>> exten
} }
OAuth2AuthorizationRequestRedirectFilter authorizationRequestFilter = new OAuth2AuthorizationRequestRedirectFilter( OAuth2AuthorizationRequestRedirectFilter authorizationRequestFilter = new OAuth2AuthorizationRequestRedirectFilter(
authorizationRequestBaseUri, this.getClientRegistrationRepository()); this.getClientRegistrationRepository(), authorizationRequestBaseUri);
if (this.authorizationEndpointConfig.authorizationRequestRepository != null) { if (this.authorizationEndpointConfig.authorizationRequestRepository != null) {
authorizationRequestFilter.setAuthorizationRequestRepository( authorizationRequestFilter.setAuthorizationRequestRepository(

View File

@ -75,11 +75,11 @@ public class OAuth2AuthorizationRequestRedirectFilter extends OncePerRequestFilt
new HttpSessionOAuth2AuthorizationRequestRepository(); new HttpSessionOAuth2AuthorizationRequestRepository();
public OAuth2AuthorizationRequestRedirectFilter(ClientRegistrationRepository clientRegistrationRepository) { public OAuth2AuthorizationRequestRedirectFilter(ClientRegistrationRepository clientRegistrationRepository) {
this(DEFAULT_AUTHORIZATION_REQUEST_BASE_URI, clientRegistrationRepository); this(clientRegistrationRepository, DEFAULT_AUTHORIZATION_REQUEST_BASE_URI);
} }
public OAuth2AuthorizationRequestRedirectFilter( public OAuth2AuthorizationRequestRedirectFilter(
String authorizationRequestBaseUri, ClientRegistrationRepository clientRegistrationRepository) { ClientRegistrationRepository clientRegistrationRepository, String authorizationRequestBaseUri) {
Assert.hasText(authorizationRequestBaseUri, "authorizationRequestBaseUri cannot be empty"); Assert.hasText(authorizationRequestBaseUri, "authorizationRequestBaseUri cannot be empty");
Assert.notNull(clientRegistrationRepository, "clientRegistrationRepository cannot be null"); Assert.notNull(clientRegistrationRepository, "clientRegistrationRepository cannot be null");

View File

@ -87,12 +87,12 @@ public class OAuth2LoginAuthenticationFilter extends AbstractAuthenticationProce
public OAuth2LoginAuthenticationFilter(ClientRegistrationRepository clientRegistrationRepository, public OAuth2LoginAuthenticationFilter(ClientRegistrationRepository clientRegistrationRepository,
OAuth2AuthorizedClientService authorizedClientService) { OAuth2AuthorizedClientService authorizedClientService) {
this(DEFAULT_FILTER_PROCESSES_URI, clientRegistrationRepository, authorizedClientService); this(clientRegistrationRepository, authorizedClientService, DEFAULT_FILTER_PROCESSES_URI);
} }
public OAuth2LoginAuthenticationFilter(String filterProcessesUrl, public OAuth2LoginAuthenticationFilter(ClientRegistrationRepository clientRegistrationRepository,
ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientService authorizedClientService,
OAuth2AuthorizedClientService authorizedClientService) { String filterProcessesUrl) {
super(filterProcessesUrl); super(filterProcessesUrl);
Assert.notNull(clientRegistrationRepository, "clientRegistrationRepository cannot be null"); Assert.notNull(clientRegistrationRepository, "clientRegistrationRepository cannot be null");
Assert.notNull(authorizedClientService, "authorizedClientService cannot be null"); Assert.notNull(authorizedClientService, "authorizedClientService cannot be null");

View File

@ -99,7 +99,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void constructorWhenAuthorizationRequestBaseUriIsNullThenThrowIllegalArgumentException() { public void constructorWhenAuthorizationRequestBaseUriIsNullThenThrowIllegalArgumentException() {
new OAuth2AuthorizationRequestRedirectFilter(null, this.clientRegistrationRepository); new OAuth2AuthorizationRequestRedirectFilter(this.clientRegistrationRepository, null);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@ -231,7 +231,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
@Test @Test
public void doFilterWhenCustomAuthorizationRequestBaseUriThenRedirectForAuthorization() throws Exception { public void doFilterWhenCustomAuthorizationRequestBaseUriThenRedirectForAuthorization() throws Exception {
String authorizationRequestBaseUri = "/custom/authorization"; String authorizationRequestBaseUri = "/custom/authorization";
this.filter = new OAuth2AuthorizationRequestRedirectFilter(authorizationRequestBaseUri, this.clientRegistrationRepository); this.filter = new OAuth2AuthorizationRequestRedirectFilter(this.clientRegistrationRepository, authorizationRequestBaseUri);
String requestUri = authorizationRequestBaseUri + "/" + this.registration1.getRegistrationId(); String requestUri = authorizationRequestBaseUri + "/" + this.registration1.getRegistrationId();
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestUri); MockHttpServletRequest request = new MockHttpServletRequest("GET", requestUri);

View File

@ -128,7 +128,7 @@ public class OAuth2LoginAuthenticationFilterTests {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void constructorWhenFilterProcessesUrlIsNullThenThrowIllegalArgumentException() { public void constructorWhenFilterProcessesUrlIsNullThenThrowIllegalArgumentException() {
new OAuth2LoginAuthenticationFilter(null, this.clientRegistrationRepository, this.authorizedClientService); new OAuth2LoginAuthenticationFilter(this.clientRegistrationRepository, this.authorizedClientService, null);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@ -241,8 +241,8 @@ public class OAuth2LoginAuthenticationFilterTests {
@Test @Test
public void doFilterWhenCustomFilterProcessesUrlThenFilterProcesses() throws Exception { public void doFilterWhenCustomFilterProcessesUrlThenFilterProcesses() throws Exception {
String filterProcessesUrl = "/login/oauth2/custom/*"; String filterProcessesUrl = "/login/oauth2/custom/*";
this.filter = spy(new OAuth2LoginAuthenticationFilter(filterProcessesUrl, this.filter = spy(new OAuth2LoginAuthenticationFilter(
this.clientRegistrationRepository, this.authorizedClientService)); this.clientRegistrationRepository, this.authorizedClientService, filterProcessesUrl));
this.filter.setAuthenticationManager(this.authenticationManager); this.filter.setAuthenticationManager(this.authenticationManager);
String requestUri = "/login/oauth2/custom/" + this.registration2.getRegistrationId(); String requestUri = "/login/oauth2/custom/" + this.registration2.getRegistrationId();