Add deduplication of policy configuration values

This commit is contained in:
Herman Slatman 2022-04-19 13:21:37 +02:00
parent f2f9cb899e
commit 9a21208f22
No known key found for this signature in database
GPG key ID: F4D8A44EA0A75A4F

View file

@ -88,6 +88,8 @@ func (par *PolicyAdminResponder) CreateAuthorityPolicy(w http.ResponseWriter, r
applyConditionalDefaults(newPolicy) applyConditionalDefaults(newPolicy)
newPolicy.Deduplicate()
adm := linkedca.AdminFromContext(ctx) adm := linkedca.AdminFromContext(ctx)
var createdPolicy *linkedca.Policy var createdPolicy *linkedca.Policy
@ -129,6 +131,8 @@ func (par *PolicyAdminResponder) UpdateAuthorityPolicy(w http.ResponseWriter, r
return return
} }
newPolicy.Deduplicate()
adm := linkedca.AdminFromContext(ctx) adm := linkedca.AdminFromContext(ctx)
var updatedPolicy *linkedca.Policy var updatedPolicy *linkedca.Policy
@ -207,6 +211,8 @@ func (par *PolicyAdminResponder) CreateProvisionerPolicy(w http.ResponseWriter,
applyConditionalDefaults(newPolicy) applyConditionalDefaults(newPolicy)
newPolicy.Deduplicate()
prov.Policy = newPolicy prov.Policy = newPolicy
if err := par.auth.UpdateProvisioner(ctx, prov); err != nil { if err := par.auth.UpdateProvisioner(ctx, prov); err != nil {
@ -241,6 +247,8 @@ func (par *PolicyAdminResponder) UpdateProvisionerPolicy(w http.ResponseWriter,
return return
} }
newPolicy.Deduplicate()
prov.Policy = newPolicy prov.Policy = newPolicy
if err := par.auth.UpdateProvisioner(ctx, prov); err != nil { if err := par.auth.UpdateProvisioner(ctx, prov); err != nil {
var pe *authority.PolicyError var pe *authority.PolicyError
@ -311,6 +319,8 @@ func (par *PolicyAdminResponder) CreateACMEAccountPolicy(w http.ResponseWriter,
return return
} }
newPolicy.Deduplicate()
eak.Policy = newPolicy eak.Policy = newPolicy
acmeEAK := linkedEAKToCertificates(eak) acmeEAK := linkedEAKToCertificates(eak)
@ -339,6 +349,8 @@ func (par *PolicyAdminResponder) UpdateACMEAccountPolicy(w http.ResponseWriter,
return return
} }
newPolicy.Deduplicate()
eak.Policy = newPolicy eak.Policy = newPolicy
acmeEAK := linkedEAKToCertificates(eak) acmeEAK := linkedEAKToCertificates(eak)
if err := par.acmeDB.UpdateExternalAccountKey(ctx, prov.GetId(), acmeEAK); err != nil { if err := par.acmeDB.UpdateExternalAccountKey(ctx, prov.GetId(), acmeEAK); err != nil {