2.2. プロパティーファイルベースのアイデンティティーストアでの認証設定
プロパティーファイルを作成します。
ユーザーとパスワードのマッピング、ユーザーとロールのマッピングの 2 つのプロパティーファイルを作成する必要があります。通常、このファイルは
jboss.server.config.dirディレクトリーにあり、*-users.propertiesおよび*-roles.propertiesの命名規則に従います。ただし、他の場所や名前を使用できます。*-users.propertiesファイルには、properties-realmへの参照も含める必要があります。これについては次の手順で作成します (#$REALM_NAME=YOUR_PROPERTIES_REALM_NAME$)。ユーザー/パスワードファイルの例: example-users.properties
#$REALM_NAME=examplePropRealm$ user1=password123 user2=password123
ユーザー/ロールファイルの例: example-roles.properties
user1=Admin user2=Guest
JBoss EAP で
properties-realmを設定します。/subsystem=elytron/properties-realm=examplePropRealm:add(groups-attribute=groups,groups-properties={path=example-roles.properties,relative-to=jboss.server.config.dir},users-properties={path=example-users.properties,relative-to=jboss.server.config.dir,plain-text=true})properties-realmの名前はexamplePropRealmで、これは 1 つ前の手順のexample-users.propertiesファイルで使用しています。また、プロパティーファイルがjboss.server.config.dir外にある場合は、pathとrelative-toの値 を適切に変更する必要があります。security-domainを設定します。/subsystem=elytron/security-domain=exampleSD:add(realms=[{realm=examplePropRealm,role-decoder=groups-to-roles}],default-realm=examplePropRealm,permission-mapper=default-permission-mapper)undertowサブシステムでapplication-security-domainを設定します。/subsystem=undertow/application-security-domain=exampleApplicationDomain:add(security-domain=exampleSD)
注記Configuration → Subsystems → Web (Undertow) → Application Security Domain に移動して、管理コンソールを使用して
undertowサブシステムのapplication-security-domainを設定できます。アプリケーションの
web.xmlおよびjboss-web.xmlを設定します。アプリケーションの
web.xmlおよびjboss-web.xmlは、JBoss EAP で設定したapplication-security-domainを使用するように更新する必要があります。このサンプルは、Configure Web Applications to use Elytron or Legacy Security for Authentication で確認できます。
これで、お使いのアプリケーションで、プロパティーファイルベースのアイデンティティーストアを使用して認証が行えるようになりました。
プロパティーファイルは、サーバーの起動時にのみ読み込まれます。ユーザーを手作業か add-user スクリプトを使用して、サーバーの起動後に追加した場合には、サーバーのリロードが必要です。このリロードは、管理 CLI から reload コマンドを実行すると実行できます。
reload