Schema Registry ACL オーソライザー¶
Schema Registry ACL オーソライザーは、サブジェクトに対する特定の Schema Registry の操作 について定義された ACL に基づく、きめの細かいオーソライザーです。Schema Registry ACL オーソライザーは、Schema Registry の ACL および認可を定義するうえで最も包括的に役立つ手段です。
注釈
SCHEMA_READ は、明示的に定義および管理ができない唯一の操作です。これは、スキーマ ID が関連付けられているサブジェクトの少なくとも 1 つに SUBJECT_READ が付与されていることに依存します。
前提条件¶
Schema Registry セキュリティプラグインのアクティブ化:
resource.extension.class=io.confluent.kafka.schemaregistry.security.SchemaRegistrySecurityResourceExtension
なんらかの形式の認証を設定しておく必要があります。詳細については、「認証メカニズム」、「Schema Registry 用 HTTP 基本認証」、または「Schema Registry 用 SSL」を参照してください。
ACL オーソライザーの有効化¶
java.security.auth.login.config
システムプロパティを設定します。
export SECURITY_PLUGINS_OPTS=-Djava.security.auth.login.config=/etc/schema-registry/kafka_client_jaas.conf
Schema Registry 構成ファイルに以下の構成を追加します。
confluent.schema.registry.authorizer.class=io.confluent.kafka.schemaregistry.security.authorizer.schemaregistryacl.SchemaRegistryAclAuthorizer
Schema Registry ACL の管理には、Schema Registry ACL CLI ツールと、以下に示す構成に基づいてそれぞれのトピックに保存された ACL を使用できます。
confluent.schema.registry.acl.topic¶
Schema Registry の操作用の ACL を保存するために使用されるトピック。これは省略可能です。この構成が使用された場合、トピック名は kafkastore.topic
として派生され、_acl
というサフィックスが使用されます。
- 型: string
Schema Registry ACL CLI は、Schema Registry プロパティの Apache Kafka® ブローカーと直接やり取りします。ACL を使用するセキュアなブローカーについては、Schema Registry ホストから直接、Schema Registry サービスと同じ認証ユーザーで、CLI を使用する必要があります。これにより、ツールで適切な ACL と、ブローカーへのアクセス権を確保できます。
Schema Registry ACL CLI¶
Schema Registry ACL は、Schema Registry ACL CLI ツールを使用して管理できます。Schema Registry ACL CLI ツールを実行すると、使用可能なオプションを確認できます。
<path-to-confluent>/bin/sr-acl-cli
Usage:
Option Description
------ -----------
-h, --help Print usage information.
--add Indicates you are trying to add ACLs.
--remove Indicates you are trying to remove ACLs.
--list List all the current ACLs
--config <File> REQUIRED: Schema Registry properties file
-o, --operation <String> Operation that is being authorized. Valid operation
names are:
[SUBJECT_READ, SUBJECT_WRITE, SUBJECT_DELETE,
SUBJECT_COMPATIBILITY_READ,
SUBJECT_COMPATIBILITY_WRITE,
GLOBAL_COMPATIBILITY_READ,
GLOBAL_COMPATIBILITY_WRITE, GLOBAL_SUBJECTS_READ]
-s, --subject <String> Subject to which the ACL is being applied to. Only
applicable for SUBJECT operations. Use * to apply
to all subjects
-t, --topic <String> Topic to which the ACL is being applied to. The
corresponding subjects would topic-key and topic-
value.Only applicable for SUBJECT operations. Use
* to apply to all subjects
-p, --principal <String> Principal to which the ACL is being applied to. Use
* to apply to all principals
ACL の追加¶
Schema Registry ACL の追加に関するさまざまな例を以下に示します。
重要
これらの例では、Confluent Platform をインストールしたホームディレクトリからコマンドを実行することが前提となっています。
ユーザー
Bob
のサブジェクトtest-subject-value
に対する書き込みアクセス権限を追加します。./bin/sr-acl-cli --config ./etc/schema-registry/schema-registry.properties --add -s test-subject-value -p Bob -o SUBJECT_WRITE
ユーザー
Bob
のサブジェクトtest-subject-key
およびtest-subject-value
に対する書き込みアクセス権限を追加します。./bin/sr-acl-cli --config ./etc/schema-registry/schema-registry.properties --add -t test-subject -p Bob -o SUBJECT_WRITE
ユーザー
Bob
のサブジェクトtest-subject-value
に対する読み取りおよび書き込みアクセス許可を追加します。./bin/sr-acl-cli --config ./etc/schema-registry/schema-registry.properties --add -s test-subject-value -p Bob -o SUBJECT_WRITE:SUBJECT_READ
ユーザー
Alice
にグローバルな互換性の管理を許可します。./bin/sr-acl-cli --config ./etc/schema-registry/schema-registry.properties --add -s test-subject-value -p Alice -o GLOBAL_COMPATIBILITY_READ:GLOBAL_COMPATIBILITY_WRITE
ワイルドカード(
*
)の使用により、dev-
から始まるトピックのグローバルな互換性の読み取り、書き込み、および管理をユーザーTed
に許可します。./bin/sr-acl-cli --config ./etc/schema-registry/schema-registry.properties --add -t dev-'*' -p Ted -o GLOBAL_COMPATIBILITY_READ:GLOBAL_COMPATIBILITY_WRITE
管理ユーザー
schema-admin
を作成します。重要
アスタリスクを引用符で囲む必要があります(
'*'
)。./bin/sr-acl-cli --config ./etc/schema-registry/schema-registry.properties --add -s '*' -p schema-admin -o '*'
ACL の削除¶
ACL の削除コマンドは、ACL の追加コマンドと似ていますが、オプションとして --add
の代わりに --remove
を使用する点が異なります。
ユーザー Bob
のサブジェクト test-subject-value
に対する書き込みアクセス権限を削除します。
./bin/sr-acl-cli --config ./etc/schema-registry/schema-registry.properties --remove -s test-subject-value -p Bob -o SUBJECT_WRITE
ACL の一覧表示¶
このコマンドでは、定義されているすべての ACL のリストが表示されます。
./bin/sr-acl-cli --config ./etc/schema-registry/schema-registry.properties --list
必須の ACL¶
トピックおよびサブジェクト に対するプリンシパルのアクセス権限の定義に加え、内部スキーマトピック(デフォルトのトピック名は _schemas
)に対して以下の ACL を指定する必要があります。
Topic: _schemas
User:registry has Allow permission for operations: Read from hosts: *
User:registry has Allow permission for operations: Write from hosts: *
User:registry has Allow permission for operations: Describe from hosts: *
User:registry has Allow permission for operations: DescribeConfigs from hosts: *
User:registry has Allow permission for operations: Create from hosts: *
Cluster
:User:registry has Allow permission for operations: Describe from hosts: *
上記の ACL が定義されていない場合、Schema Registry の起動は失敗し、トピックへのアクセスが認可されていないことを示すエラーメッセージが出力されます。
ちなみに
ACL と role-based access control (RBAC) を組み合わせて使用する場合は、Schema Registry プリンシパルを、_schemas
トピックのロールバインディングを持つグループに含める必要があります(ResourceOwner
を推奨)。これにより、サブジェクトに対する読み取り、書き込み、管理のアクセス許可が付与されます。
- Schema Registry と RBAC の詳細については、「操作に対するロールのマッピングとサブジェクトベースの認可」を参照してください。
- ACL の詳細については、「ACL を使用した認可」を参照してください。