2.2. プロパティーファイルベースのアイデンティティーストアを使用した認証の設定

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

    ユーザーがパスワードにマップされるプロパティーファイルと、ユーザーをロールにマッピングするプロパティーファイルを作成する必要があります。通常、これらのファイルは 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 の名前は、example-users.properties ファイルの前の手順で使用した、examplePropRealm です。また、プロパティーファイルが jboss.server.config.dir 外にある場合は、path および relative-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)
    注記

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

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