Go: default public key (#16265)

### What problem does this PR solve?

Provider default public key for CLI

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-06-23 17:43:26 +08:00
committed by GitHub
parent dec2ce4a60
commit e15130534f
5 changed files with 65 additions and 11 deletions

View File

@@ -517,8 +517,13 @@ func (c *CLI) AdminCreateUserCommand(cmd *Command) (ResponseIf, error) {
return nil, fmt.Errorf("password not provided")
}
publicKey, err := c.GetPublicKeyPEM()
if err != nil {
return nil, fmt.Errorf("failed to get public key: %w", err)
}
// Encrypt password using RSA
encryptedPassword, err := EncryptPassword(password)
encryptedPassword, err := EncryptPassword(password, publicKey)
if err != nil {
return nil, fmt.Errorf("failed to encrypt password: %w", err)
}
@@ -658,8 +663,13 @@ func (c *CLI) AdminAlterUserPassword(cmd *Command) (ResponseIf, error) {
return nil, fmt.Errorf("password not provided")
}
publicKey, err := c.GetPublicKeyPEM()
if err != nil {
return nil, fmt.Errorf("failed to get public key: %w", err)
}
// Encrypt password using RSA
encryptedPassword, err := EncryptPassword(password)
encryptedPassword, err := EncryptPassword(password, publicKey)
if err != nil {
return nil, fmt.Errorf("failed to encrypt password: %w", err)
}