properly handle ClientSecret updates (#1097)
This commit is contained in:
2 files changed
+14
-1
No files matched your search
@@ -169,6 +169,15 @@ func (r *Repository) UpdateAuthMethod(ctx context.Context, am *AuthMethod, versi
|
||||
return origAm, db.NoRowsAffected, nil
|
||||
}
|
||||
|
||||
// ClientSecret is a bit odd, because it uses the Struct wrapping, we need
|
||||
// to add the encrypted fields to the dbMask or nullFields
|
||||
if strutil.StrListContains(filteredDbMask, "ClientSecret") {
|
||||
filteredDbMask = append(filteredDbMask, "CtClientSecret", "ClientSecretHmac")
|
||||
}
|
||||
if strutil.StrListContains(filteredNullFields, "ClientSecret") {
|
||||
filteredNullFields = append(filteredNullFields, "CtClientSecret", "ClientSecretHmac")
|
||||
}
|
||||
|
||||
databaseWrapper, err := r.kms.GetWrapper(ctx, origAm.ScopeId, kms.KeyPurposeDatabase)
|
||||
if err != nil {
|
||||
return nil, db.NoRowsAffected, errors.Wrap(err, op, errors.WithMsg("unable to get database wrapper"))
|
||||
|
||||
@@ -76,15 +76,19 @@ func Test_UpdateAuthMethod(t *testing.T) {
|
||||
am.Name = "alice's restaurant"
|
||||
am.Description = "the best place to eat"
|
||||
am.AudClaims = []string{"www.alice.com", "www.alice.com/admin"}
|
||||
am.ClientSecret = "This is a new secret"
|
||||
return &am
|
||||
},
|
||||
fieldMasks: []string{"Name", "Description", "AudClaims"},
|
||||
fieldMasks: []string{"Name", "Description", "AudClaims", "ClientSecret"},
|
||||
version: 1,
|
||||
want: func(orig, updateWith *AuthMethod) *AuthMethod {
|
||||
am := orig.Clone()
|
||||
am.Name = updateWith.Name
|
||||
am.Description = updateWith.Description
|
||||
am.AudClaims = updateWith.AudClaims
|
||||
am.ClientSecret = updateWith.ClientSecret
|
||||
am.CtClientSecret = updateWith.CtClientSecret
|
||||
am.ClientSecretHmac = updateWith.ClientSecretHmac
|
||||
return am
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user