2.2. プロパティーファイルベースのアイデンティティーストアでの認証設定

  1. プロパティーファイルを作成します。

    ユーザーとパスワードのマッピング、ユーザーとロールのマッピングの 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

  2. 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 外にある場合は、pathrelative-to の値 を適切に変更する必要があります。

  3. security-domain を設定します。

    /subsystem=elytron/security-domain=exampleSD:add(realms=[{realm=examplePropRealm,role-decoder=groups-to-roles}],default-realm=examplePropRealm,permission-mapper=default-permission-mapper)
  4. undertow サブシステムで application-security-domain を設定します。

    /subsystem=undertow/application-security-domain=exampleApplicationDomain:add(security-domain=exampleSD)
    注記

    ConfigurationSubsystemsWeb (Undertow)Application Security Domain に移動して、管理コンソールを使用して undertow サブシステムの application-security-domain を設定できます。

  5. アプリケーションの 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