Repository navigation
feat(proxy): forward the browser user agent and pass the sign-in metrics route through - #161
Merged
Merged
Conversation
…ics route through The auth API now records a device class on every audit row, folded from the request user agent, and reports sign-in outcomes by it. The adapter is the only client it sees, so every row carried the adapter's own user agent and the breakdown read "unknown" for every sign-in. Both adapters now send the browser's User-Agent as x-seamless-client-user-agent beside x-seamless-client-ip on every proxied call, trimmed and capped at 512 characters. The API honours it under the same service-token rule as the address. GET /internal/metrics/sign-ins is proxied on an access session the way the funnel route is, with the window forwarded and pinned by the query forwarding tables and the parity cases. Depends on fells-code/seamless-auth-api#306.
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.
Adapter half of fells-code/seamless-auth-api#306 (the auth path instrumentation for fells-code/seamless-auth-api#154). Merge order: the API first, then this.
What changed
The browser's user agent is forwarded. The auth API now folds the request user agent into a device class on every audit row and reports sign-in outcomes by it. The adapter is the only client it sees, so until now every row carried this adapter's own user agent (
node) and the breakdown by device class readunknownfor every sign-in. Both adapters now send the browser'sUser-Agentasx-seamless-client-user-agentbesidex-seamless-client-ipon every proxied call. The API honours it under the same service-token rule as the address.It is trimmed and capped at 512 characters, which is what the API records. Unlike the IP it needs no trust decision: it is self-reported by the browser either way, and the API only uses it for telemetry, the session record and the magic link device binding.
buildForwardedUserAgenttolerates a request with noheaders, sincegetSeamlessUseraccepts a caller-built one (the existing tests for it pass such a request).The plumbing mirrors
forwardedClientIpexactly:authFetchtakesforwardedUserAgent, every core handler option type and passthrough carries it, and every adapter call site derives it next to the IP. That is 109 one-line additions across the three packages; there is no shorter route without a catch-all, which this repo deliberately does not have.GET /internal/metrics/sign-insis passed through, on an access session the way/internal/metrics/funnelis, with thefromandtowindow forwarded. Core exportsgetSignInMetricsHandler. All seven passthrough files from the funnel change are touched the same way.Verification
pnpm buildclean for all three packagespnpm test: core 247, express 172, fastify 69, all passingauthFetchsets the header only when given; express forwards it on an admin route and on/login(where no session exists yet) and caps an oversized one at 512; the fastify parity suite asserts both adapters forward the same value to upstream. The existing "sends no identity upstream for the public system config" parity case now pins one explicit user agent for both runners, because light-my-request sends a default and supertest sends none, and that difference showed up as a header one adapter forwarded and the other did not.minorchangeset for all three packages; READMEs describe the headerDownstream
The admin dashboard section that reads
/internal/metrics/sign-insis a separate issue in seamless-auth-admin-dashboard, linked from the API PR.