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
の名前は、example-users.properties
ファイルの前の手順で使用した、examplePropRealm
です。また、プロパティーファイルが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)
注記undertow
サブシステムのapplication-security-domain
は、Configuration → Subsystems → Web (Undertow) → Application Security Domain に移動して管理コンソールで設定できます。アプリケーションの
web.xml
およびjboss-web.xml
を設定します。JBoss EAP で設定した
application-security-domain
使用するように、アプリケーションのweb.xml
およびjboss-web.xml
を更新する必要があります。この例については、Configure Web Applications to Use Elytron or Legacy Security for Authentication で参照できます。
アプリケーションは、認証にプロパティーファイルベースのアイデンティティーストアを使用しています。
プロパティーファイルはサーバーの起動時のみ読み取られます。サーバーの起動後に、手動または add-user
スクリプトを使用して追加したユーザーは、サーバーをリロードする必要があります。このリロードは、管理 CLI から reload
コマンドを実行すると実行できます。
reload