Configure SCRAM authentication
Advanced Managed Kafka supports SASL/SCRAM, which authenticates clients that access a cluster with a username and password. Store the username and password used for authentication in a KakaoCloud Secrets Manager secret. When you associate the secret with a cluster, Advanced Managed Kafka reads the secret values and registers them as a Kafka user. To associate or disassociate a secret, you need the Advanced Managed Kafka Security Manager role.
- If you select SCRAM authentication as the client authentication method when creating a cluster, clients cannot connect to the cluster until you associate a secret.
- Advanced Managed Kafka supports the
SCRAM-SHA-512SASL/SCRAM mechanism. Other mechanisms are not supported. - You can associate up to 100 secrets with one cluster. The number of secrets you can associate follows the project's secret quota. If you increase the quota, you can associate the corresponding number of additional secrets. For more information, see Secrets Manager quotas.
Secret requirements
A secret that you associate with Advanced Managed Kafka must meet all of the following requirements.
| Item | Description |
|---|---|
| Project | The secret must be created in the same project as the cluster. |
| Name | The name must begin with amk-. Secrets with other names do not appear in the association list. You cannot change a secret name after creation. If the name is incorrect, create a new secret. |
| Value format | The secret must use key-value format and contain the username and password keys. |
| Length | Each key and value must be no more than 128 characters. |
| Status | The default version of the secret must have the Active status. You cannot associate a secret that has the Deactivated or Destroyed status. |
| Access control | If access control is configured for the secret, grant the Advanced Managed Kafka service agent permission to view the secret. |
The following is an example of the secret values.
| Key | Value |
|---|---|
username | kafka-app |
password | ******** |
Advanced Managed Kafka reads the default version of a secret. When you change a secret value, the new version becomes the default version. Update the client configuration at the same time to prevent authentication failures.
Step 1. Create secret
- Go to the KakaoCloud console > Security > Secrets Manager.
- Click [Create secret].
- Enter the following information, and then click [Create].
| Item | Description |
|---|---|
| Name | Enter a name that begins with amk-. Example: amk-order-service |
| Secret value | Add username and password as keys, and enter the username and password to use for authentication as their values. |
| Encryption key | Select the KMS key used to encrypt the secret. |
For more information about creating a secret, see Create and manage secrets.
Step 2. Configure access control (optional)
Complete this step only if access control is configured for the secret. If access control is not configured, go to Step 3.
- Go to the KakaoCloud console > Security > Secrets Manager > Secret, and select the secret you created.
- On the Access control tab, click [Add access control].
- For the target type, select Service agent account, and then add the Advanced Managed Kafka service agent account.
For more information about access control, see Configure access control.
Step 3. Associate secret with cluster
- Go to the KakaoCloud console > Analytics > Advanced Managed Kafka > Cluster.
- Click the name of the cluster with which to associate the secret.
- In the message at the top of the details page or on the Security tab, click [Associate].
- In the Associate secret popup, select the secret, and then click [Associate].
- You can associate a secret only when the cluster has the
Activestatus. - The association list shows only active secrets in the current project whose names begin with
amk-. If you created a secret, click the refresh button to update the list. - Associating a secret does not change the cluster status. Synchronizing the associated secret across all brokers can take up to 10 minutes. You can authenticate with the username and password after synchronization is complete.
After association is complete, you can view the name, description, and association date and time of the secret in the client authentication section of the Security tab.
Step 4. Configure client connection
Configure the client with the username and password values from the associated secret. The following is an example Kafka client properties file.
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-512
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \
username="kafka-app" \
password="********";
Set security.protocol according to the listener configuration of the cluster.
Disassociate secret
- Go to the Security tab on the cluster details page.
- In the client authentication section, click [Disassociate].
- Review the information in the popup, and then click [Disassociate].
- You can disassociate a secret only when the cluster has the
Activestatus. - Disassociating a secret does not change the cluster status. Synchronizing the change across all brokers can take up to 10 minutes.
When you disassociate a secret, all clients that authenticate with the secret's username and password can no longer connect to the cluster. Authentication also fails if you disable or destroy the secret in Secrets Manager.