3.3. リモーティングの Kerberos 認証統合

Kerberos を使用して管理インターフェースと web アプリケーションをセキュアにする他に、EJB などのリモーティングでアクセスされるサービスに対して Kerberos 認証を設定することもできます。

Kerberos のシステムプロパティーを設定する必要もあります。詳細は「Elytron サブシステムの設定」を参照してください。

3.3.1. レガシーセキュリティーレルムを使用した Kerberos 認証の統合

Kerberos 認証を設定するには、以下を行う必要があります。

  1. リモーティングおよび RealmDirect でのセキュリティードメインの設定

    リモーティングによってアクセスされるサービスが使用するセキュリティードメインを設定する必要があります。このセキュリティードメインは、RealmDirectRealmUsersRoles などの Remoting ログインモジュールと RealmDirect ログインモジュールの両方を利用する必要があります。本質的には、デフォルトで提供される other セキュリティードメインと大変似ています。各ログインモジュールの設定オプションの詳細は、JBoss EAP『Login Module Reference』を参照してください。

    例: Remoting および RealmDirect ログインモジュールが指定されたセキュリティードメイン

    /subsystem=security/security-domain=krb-remoting-domain:add()
    
    /subsystem=security/security-domain=krb-remoting-domain/authentication=classic:add()
    
    /subsystem=security/security-domain=krb-remoting-domain/authentication=classic/login-module=Remoting:add(code=Remoting, flag=optional, module-options=[password-stacking=useFirstPass])
    
    /subsystem=security/security-domain=krb-remoting-domain/authentication=classic/login-module=RealmDirect:add(code=RealmDirect, flag=required, module-options=[password-stacking=useFirstPass, realm=krbRealm])
    
    /subsystem=security/security-domain=krb-remoting-domain/mapping=classic:add()
    
    /subsystem=security/security-domain=krb-remoting-domain/mapping=classic/mapping-module=SimpleRoles:add(code=SimpleRoles, type=role, module-options=["testUser"="testRole"])
    
    reload

  2. Kerberos 認証のセキュリティーレルムを設定します。

    Kerberos 認証によるセキュリティーレルムのセットアップについては、「Kerberos での管理インターフェースのセキュア化」を参照してください。

    例: セキュリティーレルム

    /core-service=management/security-realm=krbRealm:add()
    
    /core-service=management/security-realm=krbRealm/server-identity=kerberos:add()
    
    /core-service=management/security-realm=krbRealm/server-identity=kerberos/keytab=remote\/localhost@JBOSS.ORG:add(path=\/path\/to\/remote.keytab, debug=true)
    
    /core-service=management/security-realm=krbRealm/authentication=kerberos:add(remove-realm=true)
    
    reload

  3. remoting サブシステムに HTTP コネクターを設定します。

    さらに、新規作成されたセキュリティーレルムを使用するために remoting サブシステムで HTTP コネクターを設定する必要があります。

    例: remoting サブシステム

    /subsystem=remoting/http-connector=http-remoting-connector:write-attribute(name=security-realm, value=krbRealm)

  4. サービスのセキュリティーを設定します。

    secured へのリモーティングインターフェースを使用してアクセスされるサービスを設定する必要もあります。この設定はサービスによって異なります。たとえば、EJB の場合、@SecurityDomain および @RolesAllowed アノテーションを使用できます。

3.3.2. Elytron を使用した Kerberos 認証の統合

Kerberos または GSSAPI SASL 認証の Elytron セキュリティードメインをリモーティング認証に対して定義できます。

  1. アイデンティティーのロード元となるセキュリティーレルムを定義します。これは、ロールの割り当てに使用されます。

    /path=kerberos:add(relative-to=user.home, path=src/kerberos)
    
    /subsystem=elytron/properties-realm=kerberos-properties:add(users-properties={path=kerberos-users.properties, relative-to=kerberos, digest-realm-name=ELYTRON.ORG}, groups-properties={path=kerberos-groups.properties, relative-to=kerberos})
  2. サーバーのアイデンティティーの Kerberos セキュリティーファクトリーを定義します。

    /subsystem=elytron/kerberos-security-factory=test-server:add(relative-to=kerberos, path=remote-test-server.keytab, principal=remote/test-server.elytron.org@ELYTRON.ORG)
  3. セキュリティードメインと SASL 認証ファクトリーを定義します。

    /subsystem=elytron/security-domain=KerberosDomain:add(default-realm=kerberos-properties, realms=[{realm=kerberos-properties, role-decoder=groups-to-roles}], permission-mapper=default-permission-mapper)
    
    /subsystem=elytron/sasl-authentication-factory=gssapi-authentication-factory:add(security-domain=KerberosDomain, sasl-server-factory=elytron, mechanism-configurations=[{mechanism-name=GSSAPI, credential-security-factory=test-server}])
  4. 作成した sasl-authentication-factoryremoting サブシステムで使用し、リモーティングで有効にします。

    CLI コマンドの例

    /subsystem=remoting/http-connector=http-remoting-connector:write-attribute(name=sasl-authentication-factory, value=gssapi-authentication-factory)

  5. サービスのセキュリティーを設定します。

    EJB でセキュリティードメインを参照する場合は、Elytron セキュリティードメインにマップする application-security-domain を指定する必要があります。たとえば EJB の場合では、@SecurityDomain アノテーションを使用できます。

    CLI コマンドの例

    /subsystem=ejb3/application-security-domain=KerberosDomain:add(security-domain=KerberosDomain)

新しい JBoss EAP 7.1 EJB クライアントでは、アイデンティティーアソシエーションへの JAAS Subject の使用はサポート対象外となりました。EJB 呼び出しの Kerberos アイデンティティーをプログラミングで管理するクライアントは、以下のように AuthenticationConfiguration API を直接使用するよう移行する必要があります。

// create your authentication configuration
AuthenticationConfiguration configuration = AuthenticationConfiguration.empty()
    .useProvidersFromClassLoader(SecuredGSSCredentialClient.class.getClassLoader())
    .useGSSCredential(getGSSCredential());

// create your authentication context
AuthenticationContext context = AuthenticationContext.empty().with(MatchRule.ALL, configuration);

// create a callable that looks up an EJB and invokes a method on it
Callable<Void> callable = () -> {
...
};

// use your authentication context to run your callable
context.runCallable(callable);

AuthenticationConfiguration の作成時に useGSSCredential(getGSSCredential()) への呼び出しが発生します。JAAS Subject へすでにアクセス済みのクライアントコードは、以下のように GSSCredential を取得するよう簡単に変換できます。

private GSSCredential getGSSCredential() {
    return Subject.doAs(subject, new PrivilegedAction<GSSCredential>() {

        public GSSCredential run() {
            try {
                GSSManager gssManager = GSSManager.getInstance();
                return gssManager.createCredential(GSSCredential.INITIATE_ONLY);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    });
}





Revised on 2019-11-27 13:00:04 CET