第2章 Elytron サブシステム

2.1. ファイルシステムベースのアイデンティティーストアでの認証設定

  1. JBoss EAP で filesystem-realm を設定します。

    /subsystem=elytron/filesystem-realm=exampleFsRealm:add(path=fs-realm-users,relative-to=jboss.server.config.dir)

    ディレクトリーが jboss.server.config.dir 外にある場合は、pathrelative-to の値を適切に変更する 必要があります。

  2. ユーザーを追加します。

    filesystem-realm を使用する場合は、管理 CLI を使用してユーザーを追加できます。

    /subsystem=elytron/filesystem-realm=exampleFsRealm:add-identity(identity=user1)
    /subsystem=elytron/filesystem-realm=exampleFsRealm:set-password(identity=user1, clear={password="password123"})
    /subsystem=elytron/filesystem-realm=exampleFsRealm:add-identity-attribute(identity=user1, name=Roles, value=["Admin","Guest"])
  3. simple-role-decoder を追加します。

    /subsystem=elytron/simple-role-decoder=from-roles-attribute:add(attribute=Roles)

    この simple-role-decoder は、Roles 属性からのプリンシパルのロールをデコードします。ロールが別の属性にある場合はこの値を変更できます。

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

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

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

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

  6. アプリケーションの 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 で確認できます。

これで、お使いのアプリケーションでファイルシステムベースのアイデンティティーストアを使用して認証を行えるようになりました。