# Kafka temporary access

Create temporary SCRAM-SHA-256 users for Apache Kafka 2.7 and later through the
[customer provisioner](/docs/guides/provisioner). Both push and outbound-only polling
use the same service, connection token, and customer authorization.

## Connect a cluster

Choose **Kafka** in **Temporary access → Add target**. List the cluster's client
broker addresses as `host:port`, separated by commas. Include every broker that can
become the controller. Connections use SASL over verified TLS; paste the private
cluster CA certificate if needed. Hostnames in the broker list must match their
certificates and the cluster's advertised addresses. IPv6 broker literals are not
currently supported.

Provide JSON with `username` and `password` for the management account. Choose
its SASL mechanism: `PLAIN`, `SCRAM-SHA-256`, or `SCRAM-SHA-512`. The account needs
cluster **Describe** and **Alter** privileges to manage SCRAM users and ACLs.
Enable `SCRAM-SHA-256` on the listener for issued users. Configure Kafka's authorizer
to deny access without matching ACLs; don't grant wildcard principals access to
protected resources. These are native Kafka credentials, not Confluent Cloud API keys
or AWS MSK IAM identities.

Configure the ACLs as JSON:

```json
[
  {"resourceType":"topic","resourceName":"events","patternType":"literal","operation":"read"},
  {"resourceType":"group","resourceName":"analytics-","patternType":"prefixed","operation":"read"}
]
```

Supported operations are topic `read`, `write`, and `describe`, plus group `read`
and `describe`. Names may be literal or prefixed. The provisioner fixes the principal
to the lease user and never grants cluster administration, user-management, or ACL
management permissions. Producers that require cluster-wide idempotent-write or
transactional-ID privileges are outside this adapter's current scope.

Everything is configured in Seekrit and encrypted to the provisioner. No Java,
Kafka tools, extra environment variables, or local target files are required.

## Lease lifecycle

The provisioner refuses existing credentials or ACLs for the lease identity. It
installs the requested ACLs before creating the SCRAM credential. The password is
generated locally and the result is encrypted directly to the requester.

Cleanup checks the credential's lease-specific salt through a TLS-protected SCRAM
challenge before removing its ACLs and credential. This also supports recovery after
a restart without storing a local ledger. If an administrator replaces the credential
or changes its authentication mechanism, ownership verification stops cleanup; remove
that replacement manually. Temporary users cannot manage their own SCRAM credentials.

Kafka has no native expiry for these credentials. Keep the provisioner connected for
scheduled cleanup. Existing authenticated connections and broker metadata propagation
can delay revocation; removing ACLs limits subsequent authorized operations. Cluster
administrators should avoid giving wildcard principals access to protected resources.

## CLI and API

Register with `seekrit dynamic target add --name events --config target.json`,
piping the management login JSON on stdin:

```json
{
  "provider": "kafka",
  "executor": "remote",
  "provisionerId": "prv_REPLACE_WITH_REGISTERED_ID",
  "settings": {
    "brokers": ["kafka.internal:9093"],
    "adminMechanism": "SCRAM-SHA-256",
    "acls": [{"resourceType":"topic","resourceName":"events","operation":"read"}]
  },
  "maxTtlSeconds": 3600
}
```

Use `seekrit dynamic lease <target-id> --ttl 1h` to request access. The result includes
the broker list, username, password, mechanism and `SASL_SSL` security protocol.
Existing member and service-token grants apply without provisioner changes.

See Apache Kafka's [SCRAM and ACL authorization reference](https://kafka.apache.org/39/security/authorization-and-acls/)
and [native protocol reference](https://kafka.apache.org/protocol.html).
