EncryptSensitiveFields encrypts all sensitive fields in a ProfileConfig. Fields that are already encrypted are left unchanged.
(profile *ProfileConfig)
| 199 | // EncryptSensitiveFields encrypts all sensitive fields in a ProfileConfig. |
| 200 | // Fields that are already encrypted are left unchanged. |
| 201 | func EncryptSensitiveFields(profile *ProfileConfig) error { |
| 202 | var err error |
| 203 | |
| 204 | if profile.Password != "" && !isEncrypted(profile.Password) { |
| 205 | profile.Password, err = EncryptField(profile.Password) |
| 206 | if err != nil { |
| 207 | return fmt.Errorf("encrypt password: %w", err) |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | if profile.TokenSecret != "" && !isEncrypted(profile.TokenSecret) { |
| 212 | profile.TokenSecret, err = EncryptField(profile.TokenSecret) |
| 213 | if err != nil { |
| 214 | return fmt.Errorf("encrypt token_secret: %w", err) |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | return nil |
| 219 | } |
| 220 | |
| 221 | // DecryptSensitiveFields decrypts all sensitive fields in a ProfileConfig. |
| 222 | // Fields that are not encrypted are left unchanged. |
no test coverage detected