Repository navigation
feat(auth): record peer address and request ID on authentication events - #4673
Merged
Merged
Conversation
Authentication events now carry the connection's immediate peer as src_endpoint, or edge-tunnel for WebSocket-tunneled requests, and the request's x-request-id as metadata.correlation_uid when it is a UUID. Refs #2912 Signed-off-by: Kris Hicks <khicks@nvidia.com>
|
🌿 Preview your docs: https://nvidia-preview-pr-4673.docs.buildwithfern.com/openshell |
Compatibility review (advisory)New or updated breaking changes; see the full report for all findings. 1. api-behavior — No explicit risk acceptance foundAuthentication events previously never included request-header values; they now write a UUID-form
Review details
Advisory review; publication gates are unchanged. |
pimlock
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Gateway authentication failure events now record where the request came from and its request ID, so operators can tell which client was rejected and join the event to other logs for the same request.
Related Issue
Refs #2912
This is the third of several PRs that together satisfy #2912, so it does not close the issue. The remaining work is listed under Follow-ups.
Changes
src_endpointis the connection's immediate peer address (IPv4-mapped IPv6 addresses are normalized to IPv4). Behind a proxy or load balancer, that is the proxy's address. Requests carried over the WebSocket tunnel endpoint recordedge-tunnelas the endpoint name.metadata.correlation_uidis the request'sx-request-id, the same value the gateway returns to the caller. Only canonical UUIDs are recorded because the header is client-controlled.Endpoint.name,Metadata.correlation_uid, andAuthenticationBuilder::correlation_uid. Shorthand output falls back to the endpoint name when there is no domain or IP.serve*entry point and attaches it to requests.RefreshSandboxTokenhandler's authentication events carry the same fields.ocsf-json-export.mdxdescribes both fields.No other request headers are recorded.
The examples below show what an authentication failure event looked like before this PR and what it looks like now, for each way a request can reach the gateway. Expand the section for details.
Before and after examples
Take a CLI whose OIDC token has expired and that calls
ListSandboxes. Before this PR, the gateway logged:The event shows that a request failed and why. It does not show who sent the request, and nothing ties it to the client's error or to the gateway's request trace. A burst of
invalid_credentialevents from one source looks the same as scattered failures from many clients.With this PR, the same request logs:
The JSONL record gains two fields. Everything else is unchanged:
{ "metadata": { "correlation_uid": "8b6f0c52-3d1e-4f7a-9c2b-5e4d3a2f1b0c", ... }, "src_endpoint": { "ip": "198.51.100.23", "port": 51234 }, ... }What each field contains depends on how the request arrived:
src_endpointmetadata.correlation_uid{"name": "edge-tunnel"}, shorthandfrom edge-tunnelx-request-idThe request ID is the
x-request-idthe gateway returns to the caller. The gateway generates one when the client sends none, so it is normally present. The same value appears asrequest_idon the gateway's request trace span, so the event can be joined to the caller's error and to the trace. Shorthand output doesn't show it; it appears only in JSONL.X-Forwarded-Foris not used because clients can set it. Tunneled requests don't yet record the address of the tunnel's own connection. That is a follow-up.Testing
cargo nextest run -p openshell-server -p openshell-ocsf(2567 passed)cargo clippy --workspace --all-targets -- -D warningscorrelation_uidmatches thex-request-idreturned to the callerFollow-ups
IssueSandboxTokenChecklist