-
Notifications
You must be signed in to change notification settings - Fork 709
Add client authentication support for ticdc #17227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0b7b2ac
Add client authentication support for ticdc
Oreoxmt 38c5039
Apply suggestions from code review
Oreoxmt 72077f2
Apply suggestions from code review
Oreoxmt e0bf5c0
Apply suggestions from code review
Oreoxmt e31f0ee
Apply suggestions from code review
Oreoxmt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| --- | ||
| title: TiCDC Client Authentication | ||
| summary: Introduce how to perform TiCDC client authentication using the command-line tool or OpenAPI. | ||
| --- | ||
|
|
||
| # TiCDC Client Authentication | ||
|
|
||
| Starting from v8.1.0, TiCDC supports client authentication using Mutual Transport Layer Security (mTLS) or TiDB username and password. | ||
|
|
||
| - mTLS authentication provides security control at the transport layer, enabling TiCDC to verify the client identity. | ||
| - TiDB username and password authentication provides security control at the application layer, ensuring that only authorized users can log in through the TiCDC node. | ||
|
|
||
| These two authentication methods can be used either independently or in combination to meet different scenarios and security requirements. | ||
|
|
||
| > **Note:** | ||
| > | ||
| > To ensure the security of network access, it is strongly recommended to use TiCDC client authentication only when [TLS is enabled](/enable-tls-between-clients-and-servers.md). If TLS is not enabled, the username and password are transmitted as plaintext over the network, which can lead to serious credential leaks. | ||
|
|
||
| ## Use mTLS for client authentication | ||
|
|
||
| 1. In the TiCDC server, configure the `security.mtls` parameter as `true` to enable mTLS authentication: | ||
|
|
||
| ```toml | ||
| [security] | ||
| # This parameter controls whether to enable the TLS client authentication. The default value is false. | ||
| mtls = true | ||
| ``` | ||
|
|
||
| 2. Configure the client certificate. | ||
|
|
||
| <SimpleTab groupId="cdc"> | ||
| <div label="TiCDC command-line tool" value="cdc-cli"> | ||
|
|
||
| When using the [TiCDC command-line tool](/ticdc/ticdc-manage-changefeed.md), you can specify the client certificate using the following methods. TiCDC will attempt to read the client certificate in the following order: | ||
|
|
||
| 1. Specify the certificate and private key using the command-line parameters `--cert` and `--key`. If the server uses a self-signed certificate, you also need to specify the trusted CA certificate using the `--ca` parameter. | ||
|
|
||
| ```bash | ||
| cdc cli changefeed list --cert client.crt --key client.key --ca ca.crt | ||
| ``` | ||
|
|
||
| 2. Specify the paths to the certificate, private key, and CA certificate using the environment variables `TICDC_CERT_PATH`, `TICDC_KEY_PATH`, and `TICDC_CA_PATH`. | ||
|
|
||
| ```bash | ||
| export TICDC_CERT_PATH=client.crt | ||
| export TICDC_KEY_PATH=client.key | ||
| export TICDC_CA_PATH=ca.crt | ||
| ``` | ||
|
|
||
| 3. Specify the certificate using the shared credential file `~/.ticdc/credentials`. You can modify the configuration using the `cdc cli configure-credentials` command. | ||
|
|
||
| </div> | ||
|
|
||
| <div label="TiCDC OpenAPI" value="cdc-api"> | ||
|
|
||
| When using [TiCDC OpenAPI](/ticdc/ticdc-open-api-v2.md), you can specify the client certificate and private key using `--cert` and `--key`. If the server uses a self-signed certificate, you also need to specify the trusted CA certificate using the `--cacert` parameter. For example: | ||
|
|
||
| ```bash | ||
| curl -X GET http://127.0.0.1:8300/api/v2/status --cert client.crt --key client.key --cacert ca.crt | ||
| ``` | ||
|
|
||
| </div> | ||
| </SimpleTab> | ||
|
|
||
| ## Use TiDB username and password for client authentication | ||
|
|
||
| 1. [Create a user](/sql-statements/sql-statement-create-user.md) in TiDB and grant the user permission to log in from the TiCDC node. | ||
|
|
||
| ```sql | ||
| CREATE USER 'test'@'ticdc_ip_address' IDENTIFIED BY 'password'; | ||
| ``` | ||
|
|
||
| 2. In the TiCDC server, configure `security.client-user-required` and `security.client-allowed-user` to enable username and password authentication: | ||
|
|
||
| ```toml | ||
| [security] | ||
| # This parameter controls whether to use username and password for client authentication. The default value is false. | ||
| client-user-required = true | ||
| # This parameter lists the usernames that are allowed for client authentication. Authentication requests with usernames not in this list will be rejected. The default value is null. | ||
| client-allowed-user = ["test"] | ||
| ``` | ||
|
|
||
| 3. Specify the username and password of the user created in step 1. | ||
|
|
||
| <SimpleTab groupId="cdc"> | ||
| <div label="TiCDC command-line tool" value="cdc-cli"> | ||
|
|
||
| When using the [TiCDC command-line tool](/ticdc/ticdc-manage-changefeed.md), you can specify the username and password using the following methods. TiCDC will attempt to read the client certificate in the following order: | ||
|
|
||
| 1. Specify the username and password using the command-line parameters `--user` and `--password`: | ||
|
|
||
| ```bash | ||
| cdc cli changefeed list --user test --password password | ||
| ``` | ||
|
|
||
| 2. Specify the username using the command-line parameter `--user`. Then, enter the password in the terminal: | ||
|
|
||
| ```bash | ||
| cdc cli changefeed list --user test | ||
| ``` | ||
|
|
||
| 3. Specify the username and password using the environment variables `TICDC_USER` and `TICDC_PASSWORD`: | ||
|
|
||
| ```bash | ||
| export TICDC_USER=test | ||
| export TICDC_PASSWORD=password | ||
| ``` | ||
|
|
||
| 4. Specify the username and password using the shared credential file `~/.ticdc/credentials`. You can modify the configuration using the `cdc cli configure-credentials` command. | ||
|
|
||
| </div> | ||
|
|
||
| <div label="TiCDC OpenAPI" value="cdc-api"> | ||
|
|
||
| When using [TiCDC OpenAPI](/ticdc/ticdc-open-api-v2.md), you can specify the username and password using `--user <user>:<password>`. For example: | ||
|
|
||
| ```bash | ||
| curl -X GET http://127.0.0.1:8300/api/v2/status --user test:password | ||
| ``` | ||
|
|
||
| </div> | ||
| </SimpleTab> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.