認証を必要とする Pulsar クラスターに接続するには、使用する認証プラグインと、指定したプラグインに必要なパラメーターを指定する必要があります。Spring Boot 自動構成を使用する場合、(ほとんどの場合) 構成プロパティを介してプラグインとプラグインパラメーターを設定できます。
例: |
認証パラメーターに環境変数を使用すると、変換中に大文字と小文字の区別が失われるため、通常は問題が発生します。例: 環境変数を介して設定された次の Spring Boot がこのプロパティをロードするとき、予想される |
Spring Boot 自動構成を使用しない場合は、org.apache.pulsar.client.api.AuthenticationFactory を使用して認証を作成し、それをクライアントファクトリに提供するクライアントカスタマイザー内の Pulsar クライアントビルダーに直接設定できます。
次のリストは、サポートされている各認証メカニズムを構成する方法を示しています。
Athenz はこちら
spring:
pulsar:
client:
authentication:
plugin-class-name: org.apache.pulsar.client.impl.auth.AuthenticationAthenz
param:
tenantDomain: ...
tenantService: ...
providerDomain: ...
privateKey: ...
keyId: ...| これには TLS 暗号化も必要です。 |
トークンはこちら
spring:
pulsar:
client:
authentication:
plugin-class-name: org.apache.pulsar.client.impl.auth.AuthenticationToken
param:
token: some-token-goes-here基本はこちら
spring:
pulsar:
client:
authentication:
plugin-class-name: org.apache.pulsar.client.impl.auth.AuthenticationBasic
param:
userId: ...
password: ...OAuth2 はこちら
spring:
pulsar:
client:
authentication:
plugin-class-name: org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2
param:
issuerUrl: ...
privateKey: ...
audience: ...
scope: ...Sasl はこちら
spring:
pulsar:
client:
authentication:
plugin-class-name: org.apache.pulsar.client.impl.auth.AuthenticationSasl
param:
saslJaasClientSectionName: ...
serverType: ...mTLS (PEM) はこちら
このオプションには TLS 暗号化が必要であり、すでにクライアントビルダーカスタマイザーを提供する必要があるため、提供された TLS カスタマイザーでクライアントビルダーに認証を直接追加することをお勧めします。org.apache.pulsar.client.api.AuthenticationFactory を使用すると、次のように認証オブジェクトの作成に役立ちます。 |
Authentication auth = AuthenticationFactory.TLS("/path/to/my-role.cert.pem", "/path/to/my-role.key-pk8.pem");mTLS (PEM) [Apache] (英語) に関する Pulsar の公式ドキュメントを参照してください。
mTLS (JKS) はこちら
このオプションには TLS 暗号化が必要であり、すでにクライアントビルダーカスタマイザーを提供する必要があるため、提供された TLS カスタマイザーでクライアントビルダーに認証を直接追加することをお勧めします。org.apache.pulsar.client.api.AuthenticationFactory を使用すると、次のように認証オブジェクトの作成に役立ちます。 |
Authentication auth = AuthenticationFactory.create(
"org.apache.pulsar.client.impl.auth.AuthenticationKeyStoreTls",
Map.of("keyStoreType", "JKS", "keyStorePath", "/path/to/my/keystore.jks", "keyStorePassword", "clientpw"));mTLS (JKS) [Apache] (英語) に関する Pulsar の公式ドキュメントを参照してください。
各サポートプラグインとその必要なプロパティの詳細については、Pulsar セキュリティ [Apache] (英語) の公式ドキュメントを参照してください。