[AUTH-12] Session device metadata (privacy-conscious) #676
All Vouch review confidence checks passed
Residual risk 0.40 = Change Risk (0.75) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #676"
general
weight: 0.35
Brunotlps
leo-aa88
Summary
Each session now records the device it signed in from, so a user can recognize it in
GET {prefix}/auth/sessionswithout the framework storing more than that needs.AuthSessiongainsuser_agent,client_addressandlocation, always present and empty when unknown. They come from the sign-in request, and refreshes keep them: the login writes them to newrefresh_tokenscolumns (user_agent,client_address,location), and every rotation copies them to its successor.locationgets the same treatment, and the cut sizes are held to the column tags by a test. The server doesn't parse it: a client that wants "Firefox on Linux" builds the label with a parser of its choice, which keeps UA sniffing out of the framework.ClientIP, soGOMBIT_HTTP_TRUSTED_PROXIESstill applies. New configGOMBIT_AUTH_SESSION_CLIENT_ADDRESS(Config.Auth.SessionClientAddress):-
coarse(the default; also what an empty value means) keeps the network, an IPv4 /24 or IPv6 /48;-
fullkeeps the whole address;-
nonekeeps nothing;- any other value is refused.
IPv4-mapped IPv6 is shown as IPv4, and zones are dropped.
auth.SessionLocator(auth.WithSessionLocator, orframework.WithAuthSessionLocator). It is called once per sign-in, before the user lock, with the full address whatever mode is set. Its answer is stored cut to 128 bytes.last_used_at: not added.last_refreshed_atalready records use at refresh time, which the issue allows, without a write on every request.Closes #662
Acceptance criteria
GET /auth/sessionsshows each session's device description in both auth modes.TestSessionDeviceHTTP/bearerand/cookielog in with a User-Agent from 203.0.113.7, refresh from another device, then list the session.coarse, and an empty value also meanscoarse. Covered byTestSessionClientAddressConfigand theclient addresstable inrunSessionDevice.recorded at sign-in, kept by refreshes(two rotations from another address and UA) and by the HTTP tests in both modes.docs/auth.md#sessionslists the three values, the columns, how each is derived, thenone/fullswitch, the locator contract, the retention (as long as the rows; nothing prunes them until #578), and the separate audit trail, which keeps the full address.Scope notes
session-device-schema(manual, breaking,refresh_tokensaltered). The same migration assession-id-schemaadds the columns. Existing rows keep NULLs and list as empty, with no backfill. Alsosession-device-metadata(informational, config:GOMBIT_AUTH_SESSION_CLIENT_ADDRESSadded).docs/upgrade-notes.mdis regenerated.docs/auth.mdstill said that revoking one session answers 404 when it rotated first. That stopped being true with #661, so I corrected it here.Validation
go test ./...: all pass except the known local-onlyTestDecimalDefaultIsAString, which needs the adminuinode_modules.go test -tags integration ./auth/against PostgreSQL and MySQL (runSessionDevicewas added to both runs, including the NUL and invalid-UTF-8 User-Agent case): passgo run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 run: 0 issuesCGO_ENABLED=0 go build ./...- rotation not copying the device;
- the coarse mode returning the full address.
- the external exchange route without request-info capture (the session-start device assertions now cover password login, MFA login in both modes, the cookie-mode external callback and the Bearer exchange).
code-reviewskill run against this diffWorking agreement checklist
examples/auth/README.mdsessions section,docs/auth.md,docs/config.md, scaffold.env.example).env.exampleand the placeholderschema.tschanged, and the goldens are regenerated.AuthSessionschema gains three fields. The scaffold's placeholderschema.tsand its goldens carry them, and no other committed spec or client does.VITE_*is treated as publicupgrade/manifest.yaml, anddocs/upgrade-notes.mdis regenerated🤖 Generated with Claude Code