クラス AuthenticationWebFilter
- java.lang.Object
-
- org.springframework.security.web.server.authentication.AuthenticationWebFilter
- 実装されたすべてのインターフェース:
org.springframework.web.server.WebFilter
- 既知の直属サブクラス
OAuth2LoginAuthenticationWebFilter
public class AuthenticationWebFilter extends java.lang.Object implements org.springframework.web.server.WebFilter
特定のリクエストの認証を実行するWebFilter
。ロジックの概要:- リクエストが受信し、
setRequiresAuthenticationMatcher(ServerWebExchangeMatcher)
と一致しない場合、このフィルターは何もせず、WebFilterChain
が続行されます。一致する場合... ServerWebExchange
をAuthentication
に変換しようとしました。結果が空の場合、フィルターはそれ以上何もせず、WebFilterChain
が続行されます。Authentication
が作成される場合...AuthenticationWebFilter(ReactiveAuthenticationManager)
で指定されたReactiveAuthenticationManager
は、認証の実行に使用されます。AuthenticationWebFilter(ReactiveAuthenticationManagerResolver)
で指定されたReactiveAuthenticationManagerResolver
は、コンテキストから適切な認証マネージャーを解決して認証を実行するために使用されます。- 認証が成功した場合、
ServerAuthenticationSuccessHandler
が呼び出され、認証がReactiveSecurityContextHolder
に設定されます。それ以外の場合、ServerAuthenticationFailureHandler
が呼び出されます
- 導入:
- 5.0
コンストラクターのサマリー
コンストラクター コンストラクター 説明 AuthenticationWebFilter(ReactiveAuthenticationManager authenticationManager)
インスタンスを作成しますAuthenticationWebFilter(ReactiveAuthenticationManagerResolver<org.springframework.web.server.ServerWebExchange> authenticationManagerResolver)
インスタンスを作成します
メソッドのサマリー
すべてのメソッド インスタンスメソッド 具象メソッド 非推奨のメソッド 修飾子と型 メソッド 説明 reactor.core.publisher.Mono<java.lang.Void>
filter(org.springframework.web.server.ServerWebExchange exchange, org.springframework.web.server.WebFilterChain chain)
protected reactor.core.publisher.Mono<java.lang.Void>
onAuthenticationSuccess(Authentication authentication, WebFilterExchange webFilterExchange)
void
setAuthenticationConverter(java.util.function.Function<org.springframework.web.server.ServerWebExchange,reactor.core.publisher.Mono<Authentication>> authenticationConverter)
使用すべきではありません。void
setAuthenticationFailureHandler(ServerAuthenticationFailureHandler authenticationFailureHandler)
認証が失敗したときに使用される失敗ハンドラーを設定します。void
setAuthenticationSuccessHandler(ServerAuthenticationSuccessHandler authenticationSuccessHandler)
認証成功ハンドラーを設定します。void
setRequiresAuthenticationMatcher(ServerWebExchangeMatcher requiresAuthenticationMatcher)
認証するsetServerAuthenticationConverter(ServerAuthenticationConverter)
からAuthentication
を作成するときに決定するために使用されるマッチャーを設定します。void
setSecurityContextRepository(ServerSecurityContextRepository securityContextRepository)
SecurityContext を永続化するためのリポジトリを設定します。void
setServerAuthenticationConverter(ServerAuthenticationConverter authenticationConverter)
ServerWebExchange
から、提供されたReactiveAuthenticationManager
での認証に使用されるAuthentication
に変換するために使用される戦略を設定します。
コンストラクターの詳細
AuthenticationWebFilter
public AuthenticationWebFilter(ReactiveAuthenticationManager authenticationManager)
インスタンスを作成します- パラメーター:
authenticationManager
- 使用する認証マネージャー
AuthenticationWebFilter
public AuthenticationWebFilter(ReactiveAuthenticationManagerResolver<org.springframework.web.server.ServerWebExchange> authenticationManagerResolver)
インスタンスを作成します- パラメーター:
authenticationManagerResolver
- 使用する認証マネージャーリゾルバー- 導入:
- 5.3
メソッドの詳細
filter
public reactor.core.publisher.Mono<java.lang.Void> filter(org.springframework.web.server.ServerWebExchange exchange, org.springframework.web.server.WebFilterChain chain)
- 次で指定:
- インターフェース
org.springframework.web.server.WebFilter
のfilter
onAuthenticationSuccess
protected reactor.core.publisher.Mono<java.lang.Void> onAuthenticationSuccess(Authentication authentication, WebFilterExchange webFilterExchange)
setSecurityContextRepository
public void setSecurityContextRepository(ServerSecurityContextRepository securityContextRepository)
SecurityContext を永続化するためのリポジトリを設定します。デフォルトはNoOpServerSecurityContextRepository
です- パラメーター:
securityContextRepository
- 使用するリポジトリ
setAuthenticationSuccessHandler
public void setAuthenticationSuccessHandler(ServerAuthenticationSuccessHandler authenticationSuccessHandler)
認証成功ハンドラーを設定します。デフォルトはWebFilterChainServerAuthenticationSuccessHandler
です- パラメーター:
authenticationSuccessHandler
- 使用する成功ハンドラー
setAuthenticationConverter
@Deprecated public void setAuthenticationConverter(java.util.function.Function<org.springframework.web.server.ServerWebExchange,reactor.core.publisher.Mono<Authentication>> authenticationConverter)
使用すべきではありません。ServerWebExchange
から、提供されたReactiveAuthenticationManager
での認証に使用されるAuthentication
に変換するために使用される戦略を設定します。結果が空の場合、認証の試行を行わないことを通知します。デフォルトのコンバーターはServerHttpBasicAuthenticationConverter
です- パラメーター:
authenticationConverter
- 使用するコンバーター- 関連事項:
setServerAuthenticationConverter(ServerAuthenticationConverter)
setServerAuthenticationConverter
public void setServerAuthenticationConverter(ServerAuthenticationConverter authenticationConverter)
ServerWebExchange
から、提供されたReactiveAuthenticationManager
での認証に使用されるAuthentication
に変換するために使用される戦略を設定します。結果が空の場合、認証の試行を行わないことを通知します。デフォルトのコンバーターはServerHttpBasicAuthenticationConverter
です- パラメーター:
authenticationConverter
- 使用するコンバーター- 導入:
- 5.1
setAuthenticationFailureHandler
public void setAuthenticationFailureHandler(ServerAuthenticationFailureHandler authenticationFailureHandler)
認証が失敗したときに使用される失敗ハンドラーを設定します。デフォルトでは、基本認証のプロンプトが表示されます。- パラメーター:
authenticationFailureHandler
- 使用するハンドラー。null にはできません。
setRequiresAuthenticationMatcher
public void setRequiresAuthenticationMatcher(ServerWebExchangeMatcher requiresAuthenticationMatcher)
認証するsetServerAuthenticationConverter(ServerAuthenticationConverter)
からAuthentication
を作成するときに決定するために使用されるマッチャーを設定します。コンバーターが空の結果を返す場合、認証は試行されません。デフォルトはすべてのリクエストです- パラメーター:
requiresAuthenticationMatcher
- 使用するマッチャー。null にはできません。