Skip to content

Commit ad4d8e6

Browse files
committed
Add SCEPCHALLENGE as valid webhook type in admin API
1 parent 419478d commit ad4d8e6

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

authority/admin/api/webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func validateWebhook(webhook *linkedca.Webhook) error {
5757

5858
// kind
5959
switch webhook.Kind {
60-
case linkedca.Webhook_ENRICHING, linkedca.Webhook_AUTHORIZING:
60+
case linkedca.Webhook_ENRICHING, linkedca.Webhook_AUTHORIZING, linkedca.Webhook_SCEPCHALLENGE:
6161
default:
62-
return admin.NewError(admin.ErrorBadRequestType, "webhook kind is invalid")
62+
return admin.NewError(admin.ErrorBadRequestType, "webhook kind %q is invalid", webhook.Kind)
6363
}
6464

6565
return nil

authority/admin/api/webhook_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ func TestWebhookAdminResponder_CreateProvisionerWebhook(t *testing.T) {
180180
statusCode: 400,
181181
}
182182
},
183+
"fail/unsupported-webhook-kind": func(t *testing.T) test {
184+
prov := &linkedca.Provisioner{
185+
Name: "provName",
186+
}
187+
ctx := linkedca.NewContextWithProvisioner(context.Background(), prov)
188+
adminErr := admin.NewError(admin.ErrorBadRequestType, `(line 5:13): invalid value for enum type: "UNSUPPORTED"`)
189+
adminErr.Message = `(line 5:13): invalid value for enum type: "UNSUPPORTED"`
190+
body := []byte(`
191+
{
192+
"name": "metadata",
193+
"url": "https://example.com",
194+
"kind": "UNSUPPORTED",
195+
}`)
196+
return test{
197+
ctx: ctx,
198+
body: body,
199+
err: adminErr,
200+
statusCode: 400,
201+
}
202+
},
183203
"fail/auth.UpdateProvisioner-error": func(t *testing.T) test {
184204
adm := &linkedca.Admin{
185205
Subject: "step",

scep/api/webhook/webhook.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ func (c *Controller) Validate(ctx context.Context, challenge string) error {
5454
return provisioner.ErrWebhookDenied
5555
}
5656

57-
// isCertTypeOK returns whether or not the webhook is for X.509
58-
// certificates.
57+
// isCertTypeOK returns whether or not the webhook can be used
58+
// with the SCEP challenge validation webhook controller.
5959
func (c *Controller) isCertTypeOK(wh *provisioner.Webhook) bool {
60+
if wh.CertType == linkedca.Webhook_ALL.String() || wh.CertType == "" {
61+
return true
62+
}
6063
return linkedca.Webhook_X509.String() == wh.CertType
6164
}

0 commit comments

Comments
 (0)