public class OAuth2LoginAuthenticationFilter extends AbstractAuthenticationProcessingFilter
AbstractAuthenticationProcessingFilter
that handles
the processing of an OAuth 2.0 Authorization Response for the authorization code grant flow.
This Filter
processes the Authorization Response as follows:
OAuth2ParameterNames.CODE
and OAuth2ParameterNames.STATE
(if provided in the Authorization Request) parameters
to the OAuth2ParameterNames.REDIRECT_URI
(provided in the Authorization Request)
and redirect the end-user's user-agent back to this Filter
(the client).
Filter
will then create an OAuth2LoginAuthenticationToken
with
the OAuth2ParameterNames.CODE
received in the previous step and delegate it to
OAuth2LoginAuthenticationProvider.authenticate(Authentication)
(indirectly via AuthenticationManager
).
AbstractAuthenticationProcessingFilter
,
OAuth2LoginAuthenticationToken
,
OAuth2AuthenticationToken
,
OAuth2LoginAuthenticationProvider
,
OAuth2AuthorizationRequest
,
OAuth2AuthorizationResponse
,
AuthorizationRequestRepository
,
OAuth2AuthorizationRequestRedirectFilter
,
ClientRegistrationRepository
,
OAuth2AuthorizedClientService
,
Section 4.1 Authorization Code Grant,
Section 4.1.2 Authorization ResponseModifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_FILTER_PROCESSES_URI |
authenticationDetailsSource, eventPublisher, messages
Constructor and Description |
---|
OAuth2LoginAuthenticationFilter(ClientRegistrationRepository clientRegistrationRepository,
OAuth2AuthorizedClientService authorizedClientService) |
OAuth2LoginAuthenticationFilter(java.lang.String filterProcessesUrl,
ClientRegistrationRepository clientRegistrationRepository,
OAuth2AuthorizedClientService authorizedClientService) |
Modifier and Type | Method and Description |
---|---|
Authentication |
attemptAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Performs actual authentication.
|
void |
setAuthorizationRequestRepository(AuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository) |
afterPropertiesSet, doFilter, getAllowSessionCreation, getAuthenticationManager, getFailureHandler, getRememberMeServices, getSuccessHandler, requiresAuthentication, setAllowSessionCreation, setApplicationEventPublisher, setAuthenticationDetailsSource, setAuthenticationFailureHandler, setAuthenticationManager, setAuthenticationSuccessHandler, setContinueChainBeforeSuccessfulAuthentication, setFilterProcessesUrl, setMessageSource, setRememberMeServices, setRequiresAuthenticationRequestMatcher, setSessionAuthenticationStrategy, successfulAuthentication, unsuccessfulAuthentication
public static final java.lang.String DEFAULT_FILTER_PROCESSES_URI
public OAuth2LoginAuthenticationFilter(ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientService authorizedClientService)
public OAuth2LoginAuthenticationFilter(java.lang.String filterProcessesUrl, ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientService authorizedClientService)
public Authentication attemptAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws AuthenticationException, java.io.IOException, javax.servlet.ServletException
AbstractAuthenticationProcessingFilter
The implementation should do one of the following:
attemptAuthentication
in class AbstractAuthenticationProcessingFilter
request
- from which to extract parameters and perform the authenticationresponse
- the response, which may be needed if the implementation has to do a
redirect as part of a multi-stage authentication process (such as OpenID).AuthenticationException
- if authentication fails.java.io.IOException
javax.servlet.ServletException
public final void setAuthorizationRequestRepository(AuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository)