Split provisioner check in two cases

This commit is contained in:
Mariano Cano 2024-05-15 16:12:15 -07:00
parent 5fa5a63de8
commit 8673818980
No known key found for this signature in database

View File

@ -334,22 +334,17 @@ func lookupJWK(next nextHTTP) nextHTTP {
// Verify that the provisioner with which the account was created // Verify that the provisioner with which the account was created
// matches the provisioner in the request URL. // matches the provisioner in the request URL.
reqProv := acme.MustProvisionerFromContext(ctx) reqProv := acme.MustProvisionerFromContext(ctx)
if acc.ProvisionerID == "" || reqProv.GetID() != acc.ProvisionerID { switch {
reqProvisioner := reqProv.GetName() case acc.ProvisionerID == "" && acc.ProvisionerName != reqProv.GetName():
accProvisioner := acc.ProvisionerName render.Error(w, acme.NewError(acme.ErrorUnauthorizedType,
if reqProvisioner != accProvisioner { "account provisioner does not match requested provisioner; account provisioner = %s, requested provisioner = %s",
// Show IDs if names are not available acc.ProvisionerName, reqProv.GetName()))
if accProvisioner == "" && acc.ProvisionerID != "" { return
reqProvisioner = reqProv.GetID() case acc.ProvisionerID != "" && acc.ProvisionerID != reqProv.GetID():
accProvisioner = acc.ProvisionerID render.Error(w, acme.NewError(acme.ErrorUnauthorizedType,
} "account provisioner does not match requested provisioner; account provisioner = %s, requested provisioner = %s",
// Provisioner in the URL must match the provisioner with acc.ProvisionerID, reqProv.GetID()))
// which the account was created. return
render.Error(w, acme.NewError(acme.ErrorUnauthorizedType,
"account provisioner does not match requested provisioner; account provisioner = %s, requested provisioner = %s",
accProvisioner, reqProvisioner))
return
}
} }
} else { } else {
// This code will only execute for old ACME accounts that do // This code will only execute for old ACME accounts that do