Propagate request ID when webhook requests are made #1542
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for propagating the request ID to the webhook receiver. The request ID is sent in the
X-Request-ID
header and uses the value that is originally created by and sent by the client in theX-Smallstep-ID
header. If it's not set, it'll be created by the CA.The request ID is propagated through a
context.Context
. This required adding theSignWithContext
method to the (TLS) authority and interfaces related to the authority. By adding the method, we can deprecate the existingSign
method, and soon default to only using the context-aware method. I think the latter makes sense, because there are already some methods that takectx
as the first argument, so we can make that the standard way.Technically, the request ID is used more like a tracing ID in this case, so I'm fine with using a different header name.X-Smallstep-ID
could be used for that? I choseX-Request-ID
because the value is reported asrequest-id
in the logs, so it's easier to ascertain that these are the same values and can be used for correlating/tracing requests to the CA and onwards to the webhook receiver.Currently this relies on the existing logic for setting the request ID based on the
logging
package, which takes the ID to forward from theX-Smallstep-Id
request header. Will follow up with a more end-to-end implementation and testing for theX-Request-ID
header.