brucearctor opened a new issue, #14968:
URL: https://github.com/apache/gravitino/issues/14968

   ### Describe the feature
   
   Add a native Kafka authorization push-down plugin module 
(`authorizations/authorization-kafka`, configured via `authorization-provider = 
"kafka"`) for `catalog-kafka` that translates Gravitino RBAC privileges, role 
bindings, and ownership changes into native Apache Kafka ACLs via Kafka's 
`AdminClient` (`createAcls`, `deleteAcls`, `describeAcls`).
   
   ### Motivation
   
   Gravitino already defines messaging/topic securable objects and topic-level 
RBAC privileges (`CREATE_TOPIC`, `PRODUCE_TOPIC`, `CONSUME_TOPIC`, plus 
ownership), and `BaseCatalog` already supports wiring an 
`AuthorizationProvider` plugin per catalog. However, Gravitino currently only 
provides authorization push-down implementations for Apache Ranger 
(`authorization-ranger`) and JDBC SQL catalogs.
   
   Modern KRaft-based Apache Kafka deployments and Kafka-compatible streaming 
engines (such as AutoMQ) rely on Kafka's built-in 
`org.apache.kafka.metadata.authorizer.StandardAuthorizer` (or `AclAuthorizer`) 
managed directly through the Kafka `AdminClient` protocol (supporting 
SASL/OAUTHBEARER, SASL/SCRAM, mTLS, etc.) without deploying Apache Ranger. 
Supporting native Kafka ACL push-down allows Gravitino to act as a unified 
control plane for topic metadata and access control across KRaft Kafka clusters 
out of the box.
   
   ### Describe the solution
   
   1. **New Module & SPI Registration (`authorizations/authorization-kafka`)**:
      - Implement `KafkaAuthorization extends 
BaseAuthorization<KafkaAuthorization>` (`shortName() = "kafka"`) registered via 
`META-INF/services/org.apache.gravitino.connector.authorization.AuthorizationProvider`,
 and wire packaging into `settings.gradle.kts` and 
`authorizations/build.gradle.kts`.
      - Reuse the Kafka catalog's `bootstrap.servers` and `gravitino.bypass.*` 
client properties (such as SASL/OAUTHBEARER, SASL/SCRAM, and SSL settings) to 
construct the `AdminClient`, with optional `authorization.kafka.*` overrides 
(e.g., configurable user/group principal prefixing, defaulting to 
`User:<principal>` and configurable group principal type, consumer group 
resource pattern, and admin request timeouts).
   
   2. **Privilege, Condition, and Securable Object Mapping**:
      - Map Gravitino `Privilege.Name` and `Privilege.Condition` (`ALLOW` / 
`DENY`) across `METALAKE`, `CATALOG`, `SCHEMA`, and `TOPIC` securable objects 
to Kafka `AclBinding` entries:
        - `CREATE_TOPIC` (`METALAKE` / `CATALOG` / `SCHEMA`): 
`ResourceType.TOPIC` (`*`, `PatternType.LITERAL`) with `AclOperation.CREATE` 
and `AclOperation.DESCRIBE`.
        - `PRODUCE_TOPIC` (`TOPIC` -> literal topic name; `METALAKE` / 
`CATALOG` / `SCHEMA` -> `*` or configured prefix): `ResourceType.TOPIC` with 
`AclOperation.WRITE` and `AclOperation.DESCRIBE` (plus 
`AclOperation.IDEMPOTENT_WRITE` on `ResourceType.CLUSTER` when `ALLOW` is 
granted and idempotent cluster-level ACLs are enabled).
        - `CONSUME_TOPIC` (`TOPIC` -> literal topic name; `METALAKE` / 
`CATALOG` / `SCHEMA` -> `*` or configured prefix): `ResourceType.TOPIC` with 
`AclOperation.READ` and `AclOperation.DESCRIBE`, plus `ResourceType.GROUP` (`*` 
or configured group pattern) `READ` / `DESCRIBE` for `ALLOW` grants so standard 
consumer groups can coordinate and fetch/commit offsets without unintended 
cross-topic `DENY` side effects.
      - **Ownership (`onOwnerSet`)**: Grant topic/catalog management and data 
operations (`READ`, `WRITE`, `CREATE`, `DELETE`, `ALTER`, `DESCRIBE`, 
`ALTER_CONFIGS`, `DESCRIBE_CONFIGS` on target `TOPIC` or `*`, plus `GROUP` 
`READ`/`DESCRIBE`) to the new owner and revoke obsolete owner ACLs from the 
previous owner.
   
   3. **Role-to-Principal Materialization & Lifecycle Cleanup**:
      - Since Kafka `StandardAuthorizer` binds ACLs directly to principals 
rather than named roles, materialize role changes (`onRoleUpdated`, 
`onRoleDeleted`) across users/groups bound to that role, and materialize 
user/group role assignments (`onGrantedRolesToUser`, `onRevokedRolesFromUser`, 
`onGrantedRolesToGroup`, `onRevokedRolesFromGroup`).
      - Reconcile overlapping grants safely so revoking one role (or 
transferring ownership) does not delete an `AclBinding` still granted to the 
same principal via another active role or ownership relation.
      - Clean up topic-scoped ACLs idempotently on 
`MetadataObjectChange.RemoveMetadataObject` when a topic is dropped (and 
migrate ACLs if renamed).
   
   4. **Testing**:
      - Unit tests mocking `AdminClient` covering privilege translation, 
`ALLOW`/`DENY`, multi-role overlap reconciliation, principal formatting, 
ownership transitions, and topic drop cleanup.
      - Docker integration test (`@Tag("gravitino-docker-test")`) running a 
real KRaft Kafka broker configured with `StandardAuthorizer` and SASL 
authentication verifying end-to-end `KafkaProducer` / `KafkaConsumer` 
enforcement on Gravitino grant, deny, and revoke operations.
   
   ### Additional context
   
   - Target compatibility: Apache Kafka 3.x+ KRaft (`StandardAuthorizer`) and 
Kafka-compatible brokers supporting the standard Kafka `CreateAcls` / 
`DeleteAcls` / `DescribeAcls` RPCs (e.g., AutoMQ).
   - Reuses the existing `kafka-clients` dependency already managed in 
`gradle/libs.versions.toml`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to