Ver Fonte

Propagate (original) request ID to webhook requests

Technically the webhook request is a new request, so maybe the
`X-Request-ID` should not be set to the value of the original
request? But then the original request ID should be propageted
in the webhook request body, or using a different header.

The way the request ID is used in this functionality is actually
more like a tracing ID, so that may be an option too.
Herman Slatman há 3 anos atrás
pai
commit
f3229d3e3c
1 ficheiros alterados com 6 adições e 0 exclusões
  1. 6 0
      authority/provisioner/webhook.go

+ 6 - 0
authority/provisioner/webhook.go

@@ -15,6 +15,7 @@ import (
 	"time"
 
 	"github.com/pkg/errors"
+	"github.com/smallstep/certificates/logging"
 	"github.com/smallstep/certificates/templates"
 	"github.com/smallstep/certificates/webhook"
 	"go.step.sm/linkedca"
@@ -169,6 +170,11 @@ retry:
 		return nil, err
 	}
 
+	requestID, ok := logging.GetRequestID(ctx)
+	if ok {
+		req.Header.Set("X-Request-ID", requestID)
+	}
+
 	secret, err := base64.StdEncoding.DecodeString(w.Secret)
 	if err != nil {
 		return nil, err