3.3.2. Elytron を使用した Kerberos 認証の統合
Kerberos または GSSAPI SASL 認証の Elytron セキュリティードメインをリモーティング認証に対して定義できます。
アイデンティティーのロード元となるセキュリティーレルムを定義します。これは、ロールの割り当てに使用されます。
/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})サーバーのアイデンティティーの 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)セキュリティードメインと 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}])作成した
sasl-authentication-factoryをremotingサブシステムで使用し、リモーティングで有効にします。CLI コマンドの例
/subsystem=remoting/http-connector=http-remoting-connector:write-attribute(name=sasl-authentication-factory, value=gssapi-authentication-factory)サービスのセキュリティーを設定します。
EJB でセキュリティードメインを参照する場合は、Elytron セキュリティードメインにマップする
application-security-domainを指定する必要があります。たとえば EJB の場合では、@SecurityDomainアノテーションを使用できます。CLI コマンドの例
/subsystem=ejb3/application-security-domain=KerberosDomain:add(security-domain=KerberosDomain)
アイデンティティアソシエーションに 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 2023-01-28 12:56:49 +1000