public class Auth2LoginAuthenticationFilter
extends org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
AbstractAuthenticationProcessingFilter for OAuth 2.0
Login.
This authentication Filter handles the processing of an OAuth 2.0 Authorization
Response for the authorization code grant flow and delegates an
OAuth2LoginAuthenticationToken to the AuthenticationManager to log in
the End-User.
The OAuth 2.0 Authorization Response is processed as follows:
code and
state parameters to the
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 code received and delegate it to the
AuthenticationManager to authenticate.OAuth2AuthenticationToken is created
(representing the End-User Principal) and associated to the
Authorized Client using the
OAuth2AuthorizedClientRepository.OAuth2AuthenticationToken is returned and ultimately stored in
the SecurityContextRepository to complete the authentication processing.AbstractAuthenticationProcessingFilter,
OAuth2LoginAuthenticationToken,
OAuth2AuthenticationToken,
OAuth2LoginAuthenticationProvider,
OAuth2AuthorizationRequest,
OAuth2AuthorizationResponse,
AuthorizationRequestRepository,
OAuth2AuthorizationRequestRedirectFilter,
ClientRegistrationRepository,
OAuth2AuthorizedClient,
OAuth2AuthorizedClientRepository,
Section
4.1 Authorization Code Grant,
Section 4.1.2 Authorization
Response| 限定符和类型 | 字段和说明 |
|---|---|
static String |
TEMPORARY_USER_CACHE_KEY_PREFIX |
static String |
TEMPORARY_USERNAME_PARAM_NAME |
| 构造器和说明 |
|---|
Auth2LoginAuthenticationFilter(String filterProcessesUrl,
String signUpUrl,
org.springframework.security.authentication.AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,?> authenticationDetailsSource,
org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory)
Constructs an
Auth2LoginAuthenticationFilter using the provided
parameters. |
| 限定符和类型 | 方法和说明 |
|---|---|
org.springframework.security.core.Authentication |
attemptAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected void |
setDetails(javax.servlet.http.HttpServletRequest request,
Auth2LoginAuthenticationToken authRequest)
Provided so that subclasses may configure what is put into the auth
request's details property.
|
void |
setRedirectStrategy(org.springframework.security.web.RedirectStrategy redirectStrategy) |
protected void |
successfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain,
org.springframework.security.core.Authentication authResult) |
afterPropertiesSet, doFilter, getAllowSessionCreation, getAuthenticationManager, getFailureHandler, getRememberMeServices, getSuccessHandler, requiresAuthentication, setAllowSessionCreation, setApplicationEventPublisher, setAuthenticationDetailsSource, setAuthenticationFailureHandler, setAuthenticationManager, setAuthenticationSuccessHandler, setContinueChainBeforeSuccessfulAuthentication, setFilterProcessesUrl, setMessageSource, setRememberMeServices, setRequiresAuthenticationRequestMatcher, setSessionAuthenticationStrategy, unsuccessfulAuthenticationpublic static final String TEMPORARY_USER_CACHE_KEY_PREFIX
public Auth2LoginAuthenticationFilter(@NonNull
String filterProcessesUrl,
@NonNull
String signUpUrl,
@Nullable
org.springframework.security.authentication.AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,?> authenticationDetailsSource,
@Autowired(required=false) @Nullable
org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory)
Auth2LoginAuthenticationFilter using the provided
parameters.filterProcessesUrl - the URI where this Filter will process
the authentication requests, not nullsignUpUrl - 第三方授权登录后如未注册用户不支持自动注册功能, 则跳转到此 url 进行注册逻辑, 此 url 必须开发者自己实现;authenticationDetailsSource - AuthenticationDetailsSourceredisConnectionFactory - redis connection factorypublic org.springframework.security.core.Authentication attemptAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws org.springframework.security.core.AuthenticationException
attemptAuthentication 在类中 org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilterorg.springframework.security.core.AuthenticationExceptionprotected void successfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain,
org.springframework.security.core.Authentication authResult)
throws IOException,
javax.servlet.ServletException
successfulAuthentication 在类中 org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilterIOExceptionjavax.servlet.ServletExceptionprotected void setDetails(javax.servlet.http.HttpServletRequest request,
Auth2LoginAuthenticationToken authRequest)
request - that an auth request is being created forauthRequest - the auth request object that should have its details
setpublic void setRedirectStrategy(org.springframework.security.web.RedirectStrategy redirectStrategy)
Copyright © 2021. All rights reserved.