クラス OAuth2LoginAuthenticationFilter

java.lang.ObjectSE
org.springframework.web.filter.GenericFilterBean
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter
実装されたすべてのインターフェース:
jakarta.servlet.Filterorg.springframework.beans.factory.Awareorg.springframework.beans.factory.BeanNameAwareorg.springframework.beans.factory.DisposableBeanorg.springframework.beans.factory.InitializingBeanorg.springframework.context.ApplicationEventPublisherAwareorg.springframework.context.EnvironmentAwareorg.springframework.context.MessageSourceAwareorg.springframework.core.env.EnvironmentCapableorg.springframework.web.context.ServletContextAware

public class OAuth2LoginAuthenticationFilter extends AbstractAuthenticationProcessingFilter
OAuth 2.0 ログイン用の AbstractAuthenticationProcessingFilter の実装。

この認証 Filter は、認可コード付与フローの OAuth 2.0 認可レスポンスの処理を処理し、OAuth2LoginAuthenticationTokenAuthenticationManager に委譲してエンドユーザーにログインします。

OAuth 2.0 認可レスポンスは次のように処理されます。

導入:
5.0
関連事項:
  • フィールドの詳細

    • DEFAULT_FILTER_PROCESSES_URI

      public static final StringSE 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
      実際の認証を実行します。

      実装では、次のいずれかを実行する必要があります。

      1. 認証されたユーザーの移入された認証トークンを返し、認証の成功を示します
      2. 認証プロセスがまだ進行中であることを示す null を返します。戻る前に、実装はプロセスを完了するために必要な追加作業を実行する必要があります。
      3. 認証プロセスが失敗した場合、 AuthenticationException をスローします
      次で指定:
      クラス AbstractAuthenticationProcessingFilterattemptAuthentication 
      パラメーター:
      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