Allow configuring oauth2 authentication handlers

Fixes gh-4472
This commit is contained in:
Joe Grandja 2017-08-21 16:51:24 -04:00
parent 93c2b2533e
commit c06975080f
1 changed files with 14 additions and 0 deletions

View File

@ -28,6 +28,8 @@ import org.springframework.security.oauth2.client.registration.ClientRegistratio
import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository;
import org.springframework.security.oauth2.client.user.OAuth2UserService;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
@ -88,6 +90,18 @@ public final class OAuth2LoginConfigurer<H extends HttpSecurityBuilder<H>> exten
return this;
}
public OAuth2LoginConfigurer<H> successHandler(AuthenticationSuccessHandler authenticationSuccessHandler) {
Assert.notNull(authenticationSuccessHandler, "authenticationSuccessHandler cannot be null");
this.authorizationCodeAuthenticationFilterConfigurer.successHandler(authenticationSuccessHandler);
return this;
}
public OAuth2LoginConfigurer<H> failureHandler(AuthenticationFailureHandler authenticationFailureHandler) {
Assert.notNull(authenticationFailureHandler, "authenticationFailureHandler cannot be null");
this.authorizationCodeAuthenticationFilterConfigurer.failureHandler(authenticationFailureHandler);
return this;
}
public AuthorizationEndpointConfig authorizationEndpoint() {
return this.authorizationEndpoint;
}