クラス SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
java.lang.ObjectSE
org.springframework.security.config.annotation.SecurityConfigurerAdapter<DefaultSecurityFilterChain,B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer < SessionManagementConfigurer <H>、H>
org.springframework.security.config.annotation.web.configurers.SessionManagementConfigurer<H>
- 実装済みのインターフェース一覧:
SecurityConfigurer<DefaultSecurityFilterChain,H>
public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
extends AbstractHttpConfigurer<SessionManagementConfigurer<H>,H>
セッション管理の構成を許可します。
セキュリティフィルター
次のフィルターが読み込まれますSessionManagementFilterConcurrentSessionFilter(ユーザーが保持できる同時セッションの数に制限がある場合)
作成された共有オブジェクト
次の共有オブジェクトが作成されます。使用される共有オブジェクト
SecurityContextRepositoryAuthenticationTrustResolverは、HttpSessionSecurityContextRepositoryおよびSessionManagementFilterを取り込むためにオプションで使用されます
- 導入:
- 3.2
- 関連事項:
ネストされたクラスの概要
ネストされたクラス修飾子と型クラス説明final class複数のセッションの制御を構成できます。final classSessionFixation 保護の構成を許可しますコンストラクター概要
コンストラクター方法の概要
修飾子と型メソッド説明addSessionAuthenticationStrategy(SessionAuthenticationStrategy sessionAuthenticationStrategy) CompositeSessionAuthenticationStrategy内で使用される追加のSessionAuthenticationStrategyを追加します。voidSecurityBuilderに必要なプロパティを設定して、SecurityBuilderを構成します。enableSessionUrlRewriting(boolean enableSessionUrlRewriting) true に設定すると、HttpServletResponse.encodeRedirectURL(String)またはHttpServletResponse.encodeURL(String)を使用するときに HTTP セッションを URL に書き換えることができます。それ以外の場合、HTTP セッションを URL に含めることはできません。voidSecurityBuilderを初期化します。invalidSessionStrategy(InvalidSessionStrategy invalidSessionStrategy) この属性を設定すると、提供された invalidSessionStrategy がSessionManagementFilterに挿入されます。invalidSessionUrl(StringSE invalidSessionUrl) この属性を設定すると、SessionManagementFilterに属性値で構成されたSimpleRedirectInvalidSessionStrategyが挿入されます。maximumSessions(int maximumSessions) ユーザーのセッションの最大数を制御します。requireExplicitAuthenticationStrategy(boolean requireExplicitAuthenticationStrategy) これを設定すると、SessionAuthenticationStrategyの明示的な呼び出しが必要になります。sessionAuthenticationErrorUrl(StringSE sessionAuthenticationErrorUrl) SessionAuthenticationStrategy が例外を発生させたときに表示されるエラーページの URL を定義します。sessionAuthenticationFailureHandler(AuthenticationFailureHandler sessionAuthenticationFailureHandler) SessionAuthenticationStrategy が例外を発生させるときに使用されるAuthenticationFailureHandlerを定義します。sessionAuthenticationStrategy(SessionAuthenticationStrategy sessionAuthenticationStrategy) SessionAuthenticationStrategyを明示的に指定できます。sessionConcurrency(Customizer<SessionManagementConfigurer<H>.ConcurrencyControlConfigurer> sessionConcurrencyCustomizer) ユーザーのセッションの最大数を制御します。sessionCreationPolicy(SessionCreationPolicy sessionCreationPolicy) SessionCreationPolicyを指定できますデフォルトのSessionFixationProtectionStrategyを変更できます。sessionFixation(Customizer<SessionManagementConfigurer<H>.SessionFixationConfigurer> sessionFixationCustomizer) セッション固定保護を構成できます。クラス org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer から継承されたメソッド
disable, getRequestMatcherBuilder, getSecurityContextHolderStrategy, withObjectPostProcessorクラス org.springframework.security.config.annotation.SecurityConfigurerAdapter から継承されたメソッド
addObjectPostProcessor, getBuilder, postProcess, setBuilder
コンストラクターの詳細
SessionManagementConfigurer
public SessionManagementConfigurer()新しいインスタンスを作成します
メソッドの詳細
invalidSessionUrl
この属性を設定すると、SessionManagementFilterに属性値で構成されたSimpleRedirectInvalidSessionStrategyが挿入されます。無効なセッション ID が送信されると、戦略が呼び出され、構成された URL にリダイレクトされます。- パラメーター:
invalidSessionUrl- 無効なセッションが検出されたときにリダイレクトする URL- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
requireExplicitAuthenticationStrategy
public SessionManagementConfigurer<H> requireExplicitAuthenticationStrategy(boolean requireExplicitAuthenticationStrategy) これを設定すると、SessionAuthenticationStrategyの明示的な呼び出しが必要になります。- パラメーター:
requireExplicitAuthenticationStrategy-SessionAuthenticationStrategyの明示的な呼び出しが必要- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
invalidSessionStrategy
public SessionManagementConfigurer<H> invalidSessionStrategy(InvalidSessionStrategy invalidSessionStrategy) この属性を設定すると、提供された invalidSessionStrategy がSessionManagementFilterに挿入されます。無効なセッション ID が送信されると、戦略が呼び出され、構成された URL にリダイレクトされます。- パラメーター:
invalidSessionStrategy- 無効なセッション ID が送信されたときに使用する戦略。- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
sessionAuthenticationErrorUrl
public SessionManagementConfigurer<H> sessionAuthenticationErrorUrl(StringSE sessionAuthenticationErrorUrl) SessionAuthenticationStrategy が例外を発生させたときに表示されるエラーページの URL を定義します。設定されていない場合、不正な (402) エラーコードがクライアントに返されます。認証が失敗した URL が優先されるフォームベースのログイン中にエラーが発生した場合、この属性は適用されないことに注意してください。- パラメーター:
sessionAuthenticationErrorUrl- リダイレクト先の URL- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
sessionAuthenticationFailureHandler
public SessionManagementConfigurer<H> sessionAuthenticationFailureHandler(AuthenticationFailureHandler sessionAuthenticationFailureHandler) SessionAuthenticationStrategy が例外を発生させるときに使用されるAuthenticationFailureHandlerを定義します。設定されていない場合、不正な (402) エラーコードがクライアントに返されます。認証が失敗した URL が優先されるフォームベースのログイン中にエラーが発生した場合、この属性は適用されないことに注意してください。- パラメーター:
sessionAuthenticationFailureHandler- 使用するハンドラー- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
enableSessionUrlRewriting
true に設定すると、HttpServletResponse.encodeRedirectURL(String)またはHttpServletResponse.encodeURL(String)を使用するときに HTTP セッションを URL に書き換えることができます。それ以外の場合、HTTP セッションを URL に含めることはできません。これにより、外部ドメインに情報が漏洩することを防ぎます。これは、
HttpServletResponse.encodeURL(java.lang.String)およびHttpServletResponse.encodeRedirectURL(java.lang.String)の呼び出しを保護することによって実現されます。ResourceUrlEncodingFilterのように、これら 2 つの方法のいずれかをオーバーライドするコードは、セキュリティフィルターチェーンの後に来る必要があります。そうしないと、スキップされるリスクがあります。- パラメーター:
enableSessionUrlRewriting- JSESSIONID を URL に書き換えられるようにする必要がある場合は true、そうでない場合は false (default)- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer - 関連事項:
sessionCreationPolicy
public SessionManagementConfigurer<H> sessionCreationPolicy(SessionCreationPolicy sessionCreationPolicy) SessionCreationPolicyを指定できます- パラメーター:
sessionCreationPolicy- 使用するSessionCreationPolicy。null にはできません。- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer - 例外:
IllegalArgumentExceptionSE-SessionCreationPolicyが null の場合。- 関連事項:
sessionAuthenticationStrategy
public SessionManagementConfigurer<H> sessionAuthenticationStrategy(SessionAuthenticationStrategy sessionAuthenticationStrategy) SessionAuthenticationStrategyを明示的に指定できます。デフォルトではChangeSessionIdAuthenticationStrategyを使用します。セッションの最大数を制限するように構成されている場合、CompositeSessionAuthenticationStrategyがConcurrentSessionControlAuthenticationStrategyに委譲します。ConcurrentSessionControlAuthenticationStrategyは、デフォルトの OR が提供するSessionAuthenticationStrategyおよびRegisterSessionAuthenticationStrategyです。NOTE: カスタム
SessionAuthenticationStrategyを指定すると、デフォルトのセッション固定戦略がオーバーライドされます。- パラメーター:
sessionAuthenticationStrategy-- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
addSessionAuthenticationStrategy
public SessionManagementConfigurer<H> addSessionAuthenticationStrategy(SessionAuthenticationStrategy sessionAuthenticationStrategy) CompositeSessionAuthenticationStrategy内で使用される追加のSessionAuthenticationStrategyを追加します。- パラメーター:
sessionAuthenticationStrategy-- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
sessionFixation
デフォルトのSessionFixationProtectionStrategyを変更できます。- 戻り値:
- さらなるカスタマイズのための
SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>.SessionFixationConfigurer
sessionFixation
public SessionManagementConfigurer<H> sessionFixation(Customizer<SessionManagementConfigurer<H>.SessionFixationConfigurer> sessionFixationCustomizer) セッション固定保護を構成できます。- パラメーター:
sessionFixationCustomizer-SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>.SessionFixationConfigurerにより多くのオプションを提供するCustomizer- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
maximumSessions
public SessionManagementConfigurer<H>.ConcurrencyControlConfigurer maximumSessions(int maximumSessions) ユーザーの最大セッション数を制御します。デフォルトでは、任意の数のセッションが許可されます。- パラメーター:
maximumSessions- ユーザーの最大セッション数- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
sessionConcurrency
public SessionManagementConfigurer<H> sessionConcurrency(Customizer<SessionManagementConfigurer<H>.ConcurrencyControlConfigurer> sessionConcurrencyCustomizer) ユーザーのセッションの最大数を制御します。デフォルトでは、任意の数のユーザーを許可します。- パラメーター:
sessionConcurrencyCustomizer-SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>.ConcurrencyControlConfigurerにより多くのオプションを提供するCustomizer- 戻り値:
- さらにカスタマイズするための
SessionManagementConfigurer
init
インターフェースからコピーされた説明:SecurityConfigurerSecurityBuilderを初期化します。ここでは、共有状態のみを作成および変更する必要がありますが、オブジェクトの構築に使用されるSecurityBuilderのプロパティは作成および変更しないでください。これにより、構築時にSecurityConfigurer.configure(SecurityBuilder)メソッドが正しい共有オブジェクトを使用するようになります。ここで設定を適用する必要があります。- 次で指定:
- インターフェース
SecurityConfigurer<DefaultSecurityFilterChain,のH extends HttpSecurityBuilder<H>> init - オーバーライド:
- クラス
SecurityConfigurerAdapter<DefaultSecurityFilterChain,のH extends HttpSecurityBuilder<H>> init
configure
インターフェースからコピーされた説明:SecurityConfigurerSecurityBuilderに必要なプロパティを設定して、SecurityBuilderを構成します。- 次で指定:
- インターフェース
SecurityConfigurer<DefaultSecurityFilterChain,のH extends HttpSecurityBuilder<H>> configure - オーバーライド:
- クラス
SecurityConfigurerAdapter<DefaultSecurityFilterChain,のH extends HttpSecurityBuilder<H>> configure