Skip to content

lightning/dumpling/dm/cdc/sync-diff-inspector: Support encrypting the MySQL password #30524

@kennytm

Description

@kennytm

Feature Request

Is your feature request related to a problem? Please describe:

Currently the MySQL password is stored as plain-text in the config.toml, which some users feel uncomfortable with.

Describe the feature you'd like:

Provide some way to hide the password. Example:

# the current situation.
[tidb]
password = "Passw0rd!!"

# same as above, only base-64 encoded
[tidb]
password = { base64 = "UGFzc3cwcmQhIQ==" }

# same as above (using TOML's dotted-key feature)
[tidb]
password.base64 = "UGFzc3cwcmQhIQ=="

# read from a file 
[tidb]
password.file = "/data/secret/lightning.txt"

# read from environment
[tidb]
password.env = "TIDB_PASSWORD"

# read from file, cached in memory, so the file can be deleted after Lightning starts
# (without caching Lightning will fetch the password from the file in case of reconnect)
[tidb]
password.cached.file = "/data/secret/lightning.txt"

# encrypted using AES-256-CTR, key read from a local file in raw binary.
[tidb]
password.aes-256-ctr = { data.base64 = "zdpUpVhoJoggKw==", key.file = "/data/secret/lightning-key.bin", nonce.base64 = "XN74TC92g2MBNbzEPpxZUA==" }

# (same as above)
[tidb.password.aes-256-ctr]
data.base64 = "zdpUpVhoJoggKw=="
key.file = "/data/secret/lightning-key.bin"
nonce.base64 = "XN74TC92g2MBNbzEPpxZUA=="

# (also same as above)
[tidb]
password.aes-256-ctr.data.base64 = "zdpUpVhoJoggKw=="
password.aes-256-ctr.key.file = "/data/secret/lightning-key.bin"
password.aes-256-ctr.nonce.base64 = "XN74TC92g2MBNbzEPpxZUA=="

# can also read the encrypted password from a binary file.
[tidb]
password.aes-256-ctr = { data.file = "/data/secret/lightning.enc", key.file = "/data/secret/lightning-key.bin", nonce.base64 = "XN74TC92g2MBNbzEPpxZUA==" }

The password will always be decrypted in the Lightning process no matter which algorithm is chosen, since the MySQL protocol demands the original password for authentication.

Describe alternatives you've considered:

Don't do it. Rely on Lightning-in-SQL.

Teachability, Documentation, Adoption, Optimization:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions