第3章 その他の機能
3.1. FORM ログインをフォールバックとして追加 リンクのコピーリンクがクリップボードにコピーされました!
JBoss EAP および JBoss EAP にデプロイされたアプリケーションでは、FORM ログイン認証メカニズムを設定してフォールバックとして使用することもできます。これにより、アプリケーションは Kerberos/SPNEGO トークンが存在しない場合の認証でログインページを提示できます。この認証は、Kerberos 認証とは独立して行われます。そのため、FORM ログインフォールバックの設定方法によっては、認証に個別のクレデンシャルが必要なことがあります。
SPNEGO または NTLM トークンが存在しない場合、または存在する SPNEGO トークンが他の KDC からである場合に、FORM ログインへのフォールバックが利用できます。
3.1.1. アプリケーションの更新 リンクのコピーリンクがクリップボードにコピーされました!
FORM ログインをフォールバックとして使用するには、アプリケーションの設定に以下の手順が必要になります。
Kerberos および SPNEGO を使用するよう JBoss EAP および web アプリケーションを設定します。
認証および承認に Kerberos および SPNEGO を使用するための、JBoss EAP および web アプリケーションの設定手順は、JBoss EAP における Kerberos での SSO のセットアップ方法 を参照してください。
ログインおよびエラーページを追加します。
FORM ログインを使用するには、ログインおよびエラーページが必要です。これらのファイルは web アプリケーションに追加され、認証プロセスで使用されます。
例:
login.jspファイル<html> <head></head> <body> <form id="login_form" name="login_form" method="post" action="j_security_check" enctype="application/x-www-form-urlencoded"> <center> <p>Please login to proceed.</p> </center> <div style="margin-left: 15px;"> <p> <label for="username">Username</label> <br /> <input id="username" type="text" name="j_username"/> </p> <p> <label for="password">Password</label> <br /> <input id="password" type="password" name="j_password" value=""/> </p> <center> <input id="submit" type="submit" name="submit" value="Login"/> </center> </div> </form> </body> </html>例:
error.jspファイル<html> <head></head> <body> <p>Login failed, please go back and try again.</p> </body> </html>web.xmlを編集します。ログインおよびエラーページを web アプリケーションに追加した後、
web.xmlを更新して FORM ログインでこれらのファイルが使用されるようにする必要があります。FORMという正確な値をそのまま<auth-method>要素に追加する必要があります。<auth-method>はコンマ区切りリストを想定し、順番が重要であるため、<auth-method>の値を正確にSPNEGO,FORMに更新する必要があります。さらに、<form-login-config>要素を<login-config>と、<form-login-page>および<form-error-page>要素として指定されたログインおよびエラーページへのパスに追加する必要があります。例: 更新された
web.xmlファイル<web-app> <display-name>App1</display-name> <description>App1</description> <!-- Define a security constraint that requires the Admin role to access resources --> <security-constraint> <display-name>Security Constraint on Conversation</display-name> <web-resource-collection> <web-resource-name>examplesWebApp</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>Admin</role-name> </auth-constraint> </security-constraint> <!-- Define the Login Configuration for this Application --> <login-config> <auth-method>SPNEGO,FORM</auth-method> <realm-name>SPNEGO</realm-name> <form-login-config> <form-login-page>/login.jsp</form-login-page> <form-error-page>/error.jsp</form-error-page> </form-login-config> </login-config> <!-- Security roles referenced by this web application --> <security-role> <description> role required to log in to the Application</description> <role-name>Admin</role-name> </security-role> </web-app>
3.1.2. Elytron サブシステムの更新 リンクのコピーリンクがクリップボードにコピーされました!
http-authentication-factoryにFORM認証のメカニズムを追加します。Kerberos ベースの認証向けに設定した既存の
http-authentication-factoryと、FORM認証の追加のメカニズムを使用できます。/subsystem=elytron/http-authentication-factory=example-krb-http-auth:list-add(name=mechanism-configurations, value={mechanism-name=FORM})フォールバックプリンシパルを追加します。
Kerberos ベースの認証向けの既存の設定には、プリンシパルを Kerberos トークンからアプリケーションのロールへマッピングするために設定されたセキュリティーレルムがすでに含まれているはずです。フォールバック認証向けの追加ユーザーをそのレルムに追加できます。たとえば、
filesystem-realmを使用する場合、適切なロールを持つ新規ユーザーを作成できます。
/subsystem=elytron/filesystem-realm=exampleFsRealm:add-identity(identity=fallbackUser1)
/subsystem=elytron/filesystem-realm=exampleFsRealm:set-password(identity=fallbackUser1, clear={password="password123"})
/subsystem=elytron/filesystem-realm=exampleFsRealm:add-identity-attribute(identity=fallbackUser1, name=Roles, value=["Admin","Guest"])
3.1.3. レガシー Security サブシステムの更新 リンクのコピーリンクがクリップボードにコピーされました!
JBoss EAP でレガシー security サウシステムを使用している場合は、フォールバック認証のセキュリティードメインを更新する必要があります。
web アプリケーションセキュリティードメインを設定して、フォールバックログインメカニズムをサポートする必要があります。これには以下の手順が必要になります。
- フォールバック認証メソッドとして対応する新しいセキュリティードメインを追加します。
-
usernamePasswordDomainモジュールオプションを、フォールバックドメインを示す web アプリケーションセキュリティードメインに追加します。
例: フォールバックセキュリティードメインで設定されたセキュリティードメイン
/subsystem=security/security-domain=app-fallback:add(cache-type=default)
/subsystem=security/security-domain=app-fallback/authentication=classic:add()
/subsystem=security/security-domain=app-fallback/authentication=classic/login-module=UsersRoles:add(code=UsersRoles, flag=required, module-options=[usersProperties="file:${jboss.server.config.dir}/fallback-users.properties", rolesProperties="file:${jboss.server.config.dir}/fallback-roles.properties"])
/subsystem=security/security-domain=app-spnego/authentication=classic/login-module=SPNEGO:add(code=SPNEGO, flag=required, module-options=[serverSecurityDomain=host])
/subsystem=security/security-domain=app-spnego/authentication=classic/login-module=SPNEGO:map-put(name=module-options, key=usernamePasswordDomain, value=app-fallback)
/subsystem=security/security-domain=app-spnego/authentication=classic/login-module=SPNEGO:map-put(name=module-options, key=password-stacking, value=useFirstPass)
reload