クラス OAuth2LoginAuthenticationFilter
java.lang.ObjectSE
org.springframework.web.filter.GenericFilterBean
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter
- 実装されたすべてのインターフェース:
jakarta.servlet.Filter
、org.springframework.beans.factory.Aware
、org.springframework.beans.factory.BeanNameAware
、org.springframework.beans.factory.DisposableBean
、org.springframework.beans.factory.InitializingBean
、org.springframework.context.ApplicationEventPublisherAware
、org.springframework.context.EnvironmentAware
、org.springframework.context.MessageSourceAware
、org.springframework.core.env.EnvironmentCapable
、org.springframework.web.context.ServletContextAware
OAuth 2.0 ログイン用の
AbstractAuthenticationProcessingFilter
の実装。 この認証 Filter
は、認可コード付与フローの OAuth 2.0 認可レスポンスの処理を処理し、OAuth2LoginAuthenticationToken
を AuthenticationManager
に委譲してエンドユーザーにログインします。
OAuth 2.0 認可レスポンスは次のように処理されます。
- エンドユーザー(リソース所有者)がクライアントへのアクセスを認可したと仮定すると、認可サーバーは
code
およびstate
パラメーターをredirect_uri
(認可リクエストで提供)に追加し、エンドユーザーのユーザーエージェントをこのFilter
にリダイレクトします(クライアント)。 - この
Filter
は、受け取ったcode
でOAuth2LoginAuthenticationToken
を作成し、それをAuthenticationManager
に委譲して認証します。 - 認証が成功すると、
OAuth2AuthenticationToken
が作成され(エンドユーザーPrincipal
を表す)、OAuth2AuthorizedClientRepository
を使用してAuthorized Client
に関連付けられます。 - 最後に、
OAuth2AuthenticationToken
が返され、最終的にSecurityContextRepository
に格納されて、認証処理が完了します。
- 導入:
- 5.0
- 関連事項:
AbstractAuthenticationProcessingFilter
OAuth2LoginAuthenticationToken
OAuth2AuthenticationToken
OAuth2LoginAuthenticationProvider
OAuth2AuthorizationRequest
OAuth2AuthorizationResponse
AuthorizationRequestRepository
OAuth2AuthorizationRequestRedirectFilter
ClientRegistrationRepository
OAuth2AuthorizedClient
OAuth2AuthorizedClientRepository
- セクション 4.1 認可コードの付与
- セクション 4.1.2 認可レスポンス
フィールドサマリー
フィールドクラス org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter から継承されたフィールド
authenticationDetailsSource, eventPublisher, messages
クラス org.springframework.web.filter.GenericFilterBean から継承されたフィールド
logger
コンストラクターのサマリー
コンストラクターコンストラクター説明OAuth2LoginAuthenticationFilter
(ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientService authorizedClientService) 指定されたパラメーターを使用してOAuth2LoginAuthenticationFilter
を構築します。OAuth2LoginAuthenticationFilter
(ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientService authorizedClientService, StringSE filterProcessesUrl) 指定されたパラメーターを使用してOAuth2LoginAuthenticationFilter
を構築します。OAuth2LoginAuthenticationFilter
(ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientRepository authorizedClientRepository, StringSE filterProcessesUrl) 指定されたパラメーターを使用してOAuth2LoginAuthenticationFilter
を構築します。メソッドのサマリー
修飾子と型メソッド説明attemptAuthentication
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) 実際の認証を実行します。final void
setAuthenticationResultConverter
(org.springframework.core.convert.converter.Converter<OAuth2LoginAuthenticationToken, OAuth2AuthenticationToken> authenticationResultConverter) OAuth2LoginAuthenticationToken
からOAuth2AuthenticationToken
認証結果への変換を担当するコンバーターを設定します。final void
setAuthorizationRequestRepository
(AuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository) 格納されたOAuth2AuthorizationRequest
のリポジトリを設定します。クラス org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter から継承されたメソッド
afterPropertiesSet, doFilter, getAllowSessionCreation, getAuthenticationManager, getFailureHandler, getRememberMeServices, getSuccessHandler, requiresAuthentication, setAllowSessionCreation, setApplicationEventPublisher, setAuthenticationDetailsSource, setAuthenticationFailureHandler, setAuthenticationManager, setAuthenticationSuccessHandler, setContinueChainBeforeSuccessfulAuthentication, setFilterProcessesUrl, setMessageSource, setRememberMeServices, setRequiresAuthenticationRequestMatcher, setSecurityContextHolderStrategy, setSecurityContextRepository, setSessionAuthenticationStrategy, successfulAuthentication, unsuccessfulAuthentication
クラス org.springframework.web.filter.GenericFilterBean から継承されたメソッド
addRequiredProperty, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
フィールドの詳細
DEFAULT_FILTER_PROCESSES_URI
このFilter
が認証リクエストを処理するデフォルトのURI
。- 関連事項:
コンストラクターの詳細
OAuth2LoginAuthenticationFilter
public OAuth2LoginAuthenticationFilter(ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientService authorizedClientService) 指定されたパラメーターを使用してOAuth2LoginAuthenticationFilter
を構築します。- パラメーター:
clientRegistrationRepository
- クライアント登録のリポジトリauthorizedClientService
- 認可されたクライアントサービス
OAuth2LoginAuthenticationFilter
public OAuth2LoginAuthenticationFilter(ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientService authorizedClientService, StringSE filterProcessesUrl) 指定されたパラメーターを使用してOAuth2LoginAuthenticationFilter
を構築します。- パラメーター:
clientRegistrationRepository
- クライアント登録のリポジトリauthorizedClientService
- 認可されたクライアントサービスfilterProcessesUrl
- このFilter
が認証リクエストを処理するURI
OAuth2LoginAuthenticationFilter
public OAuth2LoginAuthenticationFilter(ClientRegistrationRepository clientRegistrationRepository, OAuth2AuthorizedClientRepository authorizedClientRepository, StringSE filterProcessesUrl) 指定されたパラメーターを使用してOAuth2LoginAuthenticationFilter
を構築します。- パラメーター:
clientRegistrationRepository
- クライアント登録のリポジトリauthorizedClientRepository
- 認可されたクライアントリポジトリfilterProcessesUrl
- このFilter
が認証リクエストを処理するURI
- 導入:
- 5.1
メソッドの詳細
attemptAuthentication
public Authentication attemptAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws AuthenticationException クラスからコピーされた説明:AbstractAuthenticationProcessingFilter
実際の認証を実行します。実装では、次のいずれかを実行する必要があります。
- 認証されたユーザーの移入された認証トークンを返し、認証の成功を示します
- 認証プロセスがまだ進行中であることを示す null を返します。戻る前に、実装はプロセスを完了するために必要な追加作業を実行する必要があります。
- 認証プロセスが失敗した場合、 AuthenticationException をスローします
- 次で指定:
- クラス
AbstractAuthenticationProcessingFilter
のattemptAuthentication
- パラメーター:
request
- パラメーターの抽出元および認証の実行元response
- レスポンス。これは、実装が多段階認証プロセス (OIDC など) の一部としてリダイレクトを行う必要がある場合に必要になる場合があります。- 戻り値:
- 認証されたユーザートークン。認証が不完全な場合は null
- 例外:
AuthenticationException
- 認証が失敗した場合。
setAuthorizationRequestRepository
public final void setAuthorizationRequestRepository(AuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository) 格納されたOAuth2AuthorizationRequest
のリポジトリを設定します。- パラメーター:
authorizationRequestRepository
- 保存されたOAuth2AuthorizationRequest
のリポジトリ
setAuthenticationResultConverter
public final void setAuthenticationResultConverter(org.springframework.core.convert.converter.Converter<OAuth2LoginAuthenticationToken, OAuth2AuthenticationToken> authenticationResultConverter) OAuth2LoginAuthenticationToken
からOAuth2AuthenticationToken
認証結果への変換を担当するコンバーターを設定します。- パラメーター:
authenticationResultConverter
-OAuth2AuthenticationToken
用のコンバーター- 導入:
- 5.6