Skip to content

feat(auth): reuse the auth session's device id at finalize (campus#825) - #96

Merged
nycomp merged 1 commit into
mainfrom
feat/825-device-id
Oct 5, 2026
Merged

nycomp merged 1 commit into
mainfrom
feat/825-device-id

Conversation

@nycomp

@nycomp nycomp commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Implements the SDK half of the stable-device design accepted in nyjc-computing/campus#825 (design comment).

What changes

  • finalize() reuses the auth session's device_id when campus.auth observed one (the stable campus_device cookie, recorded on the auth session by campus#832), instead of always minting a fresh per-login id. Re-logins from the same browser profile therefore land on the same device id, and the login sessions they create — whose device_id the tracing middleware stamps onto spans — attribute to a device, not just a user.
  • Minted fallback retained for non-cookie flows and pre-#825 auth services (degrades to per-login ids, as today).
  • Lock bump: campus-suite → 14fc6a9 (adds AuthSession.device_id; campus PR #832).

Test plan

  • New tests/unit/test_finalize_device_id.py: session device id rides through unchanged; absent → minted uid-device-*; both paths produce the same id shape (mock-driven, exercises the real campus.model.AuthSession.from_resource path).
  • Full unit suite: 246 OK; ruff clean on changed files (the I001 on auth/v1/__init__.py is pre-existing on main).

Ref nyjc-computing/campus#825

campus.auth now observes a stable campus_device cookie at /authorize
and records the id on the auth session. finalize() copies that id onto
the login session it creates instead of always minting a fresh one, so
re-logins from the same browser profile land on the same device id and
audit spans attribute to the device, not just the user. The minted
fallback keeps non-cookie flows and pre-#825 auth services working.

Lock bump: campus-suite -> 14fc6a9 (AuthSession.device_id).

Refs nyjc-computing/campus#825
@nycomp
nycomp merged commit 138931f into main Oct 5, 2026
2 checks passed
@nycomp
nycomp deleted the feat/825-device-id branch October 5, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants