Skip to content

Commit

Permalink
[MM-1137]: Fixed the secrets error found by QA
Browse files Browse the repository at this point in the history
  • Loading branch information
Kshitij-Katiyar committed Jan 7, 2025
1 parent fbb2462 commit d48c119
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
"display_name": "At Rest Encryption Key:",
"type": "generated",
"help_text": "The encryption key used to encrypt stored API tokens.",
"placeholder": "",
"default": null,
"secret": true
},
{
Expand Down
11 changes: 10 additions & 1 deletion server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (p *Plugin) OnConfigurationChange() error {
return err
}

encryptionKey := p.getConfig().EncryptionKey
encryptionKey := ec.EncryptionKey
if encryptionKey == "" {
p.client.Log.Warn("Encryption key required to encrypt admin API token")
return errors.New("failed to encrypt admin token. Encryption key not generated")
Expand Down Expand Up @@ -540,6 +540,15 @@ func (c *externalConfig) setDefaults() (bool, error) {
changed = true
}

if c.EncryptionKey == "" {
encryptionKey, err := generateSecret()
if err != nil {
return false, err
}
c.EncryptionKey = encryptionKey
changed = true
}

return changed, nil
}

Expand Down

0 comments on commit d48c119

Please sign in to comment.