クラス FormLoginConfigurer<H extends HttpSecurityBuilder<H>>
java.lang.ObjectSE
org.springframework.security.config.annotation.SecurityConfigurerAdapter<DefaultSecurityFilterChain,B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<T,B>
org.springframework.security.config.annotation.web.configurers.AbstractAuthenticationFilterConfigurer <H、FormLoginConfigurer <H>、UsernamePasswordAuthenticationFilter >
org.springframework.security.config.annotation.web.configurers.FormLoginConfigurer<H>
- 実装されたすべてのインターフェース:
SecurityConfigurer<DefaultSecurityFilterChain,
H>
public final class FormLoginConfigurer<H extends HttpSecurityBuilder<H>>
extends AbstractAuthenticationFilterConfigurer<H,FormLoginConfigurer<H>,UsernamePasswordAuthenticationFilter>
フォームベースの認証を追加します。すべての属性には妥当なデフォルトがあり、すべてのパラメーターはオプションです。
loginPage(String)
が指定されていない場合、デフォルトのログインページがフレームワークによって生成されます。セキュリティフィルター
次のフィルターが読み込まれます作成された共有オブジェクト
次の共有オブジェクトが入力されます使用される共有オブジェクト
次の共有オブジェクトが使用されます。AuthenticationManager
RememberMeServices
- オプションで使用されます。RememberMeConfigurer
を参照SessionAuthenticationStrategy
- オプションで使用されます。SessionManagementConfigurer
を参照DefaultLoginPageGeneratingFilter
- 存在する場合、構成からの情報が入力されます
- 導入:
- 3.2
コンストラクターのサマリー
コンストラクターメソッドのサマリー
修飾子と型メソッド説明protected RequestMatcher
createLoginProcessingUrlMatcher
(StringSE loginProcessingUrl) loginProcessingUrl を指定してRequestMatcher
を作成しますfailureForwardUrl
(StringSE forwardUrl) フォワード認証失敗ハンドラーvoid
SecurityBuilder
を初期化します。ログインが必要な場合にユーザーを送信する URL を指定します。passwordParameter
(StringSE passwordParameter) 認証を実行するときにパスワードを探す HTTP パラメーター。successForwardUrl
(StringSE forwardUrl) フォワード認証成功ハンドラーusernameParameter
(StringSE usernameParameter) 認証を実行するときにユーザー名を探す HTTP パラメーター。クラス org.springframework.security.config.annotation.web.configurers.AbstractAuthenticationFilterConfigurer から継承されたメソッド
authenticationDetailsSource, configure, defaultSuccessUrl, defaultSuccessUrl, failureHandler, failureUrl, getAuthenticationEntryPoint, getAuthenticationEntryPointMatcher, getAuthenticationFilter, getFailureUrl, getLoginPage, getLoginProcessingUrl, isCustomLoginPage, loginProcessingUrl, permitAll, permitAll, registerAuthenticationEntryPoint, registerDefaultAuthenticationEntryPoint, securityContextRepository, setAuthenticationFilter, successHandler, updateAccessDefaults, updateAuthenticationDefaults
クラス org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer から継承されたメソッド
disable, getSecurityContextHolderStrategy, withObjectPostProcessor
クラス org.springframework.security.config.annotation.SecurityConfigurerAdapter から継承されたメソッド
addObjectPostProcessor, and, getBuilder, postProcess, setBuilder
コンストラクターの詳細
FormLoginConfigurer
public FormLoginConfigurer()新しいインスタンスを作成します
メソッドの詳細
loginPage
ログインが必要な場合にユーザーを送信する URL を指定します。
EnableWebSecurity
で使用すると、この属性が指定されていない場合にデフォルトのログインページが生成されます。URL が指定されている場合、またはこれが
EnableWebSecurity
と組み合わせて使用されていない場合、ユーザーは指定された URL を処理してログインページを生成する必要があります。一般に、ログインページは、UsernamePasswordAuthenticationFilter
を使用するために、次の要件を備えたリクエストを送信するフォームを作成する必要があります。- HTTP POST である必要があります
AbstractAuthenticationFilterConfigurer.loginProcessingUrl(String)
に提出する必要がありますusernameParameter(String)
という名前の HTTP パラメーターとしてユーザー名を含める必要がありますpasswordParameter(String)
という名前の HTTP パラメーターとしてパスワードを含める必要があります
login.jsp の例
上記のルールが守られている限り、選択したテクノロジーでログインページをレンダリングできます。以下は、JSP を使用する際のクイックスタートとして、または別のビューテクノロジーに変換するためのベースラインとして使用できる login.jsp の例です。<c:url value="/login" var="loginProcessingUrl"/> <form action="${loginProcessingUrl}" method="post"> <fieldset> <legend>Please Login</legend> <!-- use param.error assuming FormLoginConfigurer#failureUrl contains the query parameter error --> <c:if test="${param.error != null}"> <div> Failed to login. <c:if test="${SPRING_SECURITY_LAST_EXCEPTION != null}"> Reason: <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" /> </c:if> </div> </c:if> <!-- the configured LogoutConfigurer#logoutSuccessUrl is /login?logout and contains the query param logout --> <c:if test="${param.logout != null}"> <div> You have been logged out. </div> </c:if> <p> <label for="username">Username</label> <input type="text" id="username" name="username"/> </p> <p> <label for="password">Password</label> <input type="password" id="password" name="password"/> </p> <!-- if using RememberMeConfigurer make sure remember-me matches RememberMeConfigurer#rememberMeParameter --> <p> <label for="remember-me">Remember Me?</label> <input type="checkbox" id="remember-me" name="remember-me"/> </p> <div> <button type="submit" class="btn">Log in</button> </div> </fieldset> </form>
他のデフォルトへの影響
この値を更新すると、他の多くのデフォルト値にも影響します。例: formLogin() のみが指定された場合のデフォルト値は次のとおりです。- /login GET - the login form
- /login POST - process the credentials and if valid authenticate the user
- /login?error GET - redirect here for failed authentication attempts
- /login?logout GET - redirect here after successfully logging out
- /authenticate GET - the login form
- /authenticate POST - process the credentials and if valid authenticate the user
- /authenticate?error GET - redirect here for failed authentication attempts
- /authenticate?logout GET - redirect here after successfully logging out
- オーバーライド:
- クラス
AbstractAuthenticationFilterConfigurer<H extends HttpSecurityBuilder<H>,
のFormLoginConfigurer<H extends HttpSecurityBuilder<H>>, UsernamePasswordAuthenticationFilter> loginPage
- パラメーター:
loginPage
- 認証が必要な場合にリダイレクトするログインページ (つまり、"/login")- 戻り値:
- 追加のカスタマイズのための
FormLoginConfigurer
usernameParameter
認証を実行するときにユーザー名を探す HTTP パラメーター。デフォルトは "username" です。- パラメーター:
usernameParameter
- 認証を実行するときにユーザー名を探す HTTP パラメーター- 戻り値:
- 追加のカスタマイズのための
FormLoginConfigurer
passwordParameter
認証を実行するときにパスワードを探す HTTP パラメーター。デフォルトは "password" です。- パラメーター:
passwordParameter
- 認証を実行するときにパスワードを探す HTTP パラメーター- 戻り値:
- 追加のカスタマイズのための
FormLoginConfigurer
failureForwardUrl
フォワード認証失敗ハンドラー- パラメーター:
forwardUrl
- 失敗した場合のターゲット URL- 戻り値:
- 追加のカスタマイズのための
FormLoginConfigurer
successForwardUrl
フォワード認証成功ハンドラー- パラメーター:
forwardUrl
- 成功した場合のターゲット URL- 戻り値:
- 追加のカスタマイズのための
FormLoginConfigurer
init
インターフェースからコピーされた説明:SecurityConfigurer
SecurityBuilder
を初期化します。ここでは、共有状態のみを作成および変更する必要がありますが、オブジェクトの構築に使用されるSecurityBuilder
のプロパティは作成および変更しないでください。これにより、構築時にSecurityConfigurer.configure(SecurityBuilder)
メソッドが正しい共有オブジェクトを使用するようになります。ここで設定を適用する必要があります。- 次で指定:
- インターフェース
SecurityConfigurer<DefaultSecurityFilterChain,
のH extends HttpSecurityBuilder<H>> init
- オーバーライド:
- クラス
AbstractAuthenticationFilterConfigurer<H extends HttpSecurityBuilder<H>,
のFormLoginConfigurer<H extends HttpSecurityBuilder<H>>, UsernamePasswordAuthenticationFilter> init
- 例外:
ExceptionSE
createLoginProcessingUrlMatcher
クラスからコピーされた説明:AbstractAuthenticationFilterConfigurer
loginProcessingUrl を指定してRequestMatcher
を作成します- 次で指定:
- クラス
AbstractAuthenticationFilterConfigurer<H extends HttpSecurityBuilder<H>,
のFormLoginConfigurer<H extends HttpSecurityBuilder<H>>, UsernamePasswordAuthenticationFilter> createLoginProcessingUrlMatcher
- パラメーター:
loginProcessingUrl
- loginProcessingUrl に基づいてRequestMatcher
を作成します- 戻り値:
- loginProcessingUrl に基づいて使用する
RequestMatcher