Skip to content

feat(BA-6152): track originating client IP on active login_sessions#11755

Draft
jopemachine wants to merge 1 commit into
feat/BA-5733-login-history-client-ipfrom
feat/BA-6152-login-session-client-ip
Draft

feat(BA-6152): track originating client IP on active login_sessions#11755
jopemachine wants to merge 1 commit into
feat/BA-5733-login-history-client-ipfrom
feat/BA-6152-login-session-client-ip

Conversation

@jopemachine
Copy link
Copy Markdown
Member

@jopemachine jopemachine commented May 22, 2026

Summary

Mirror the BA-5733 client_ip work on the active session table (BA-5733 only added the column to login_history). With this change, the manager can answer ‘where am I currently logged in from?’ and ‘show me / revoke all active sessions originating from IP X’ without joining against possibly-pruned history rows.

  • Adds a nullable client_ip VARCHAR(45) column to login_sessions via a new Alembic migration (c4d2f8b6e9a1) chained after BA-5733's a1b3e7c2d4f5.
  • Populates the column inside create_login_session alongside the existing SUCCESS login_history row, using the same client_ip argument the service already threads in.
  • Exposes clientIp on LoginSessionV2 (Strawberry) and the v2 REST LoginSessionNode.
  • Adds client_ip to LoginSessionFilter and a CLIENT_IP value to LoginSessionOrderField (DTO + GraphQL inputs), with matching LoginSessionConditions.by_client_ip_* + LoginSessionOrders.client_ip helpers and adapter wiring.
  • Regenerates the supergraph / v2 schema dumps.
  • Adds a unit test under tests/unit/manager/repositories/auth/ confirming the supplied client_ip lands on the session row (and falls back to NULL when not provided).

Resolves BA-6152.

Stack

Stacked on top of #11733 (BA-5733 — client_ip on login_history). This PR's base branch is `feat/BA-5733-login-history-client-ip`; rebase onto `main` once #11733 merges.

Test plan

  • `pants fmt --changed-since=origin/main` — clean
  • `pants lint --changed-since=origin/main` — clean
  • `pants check --changed-since=origin/main` — mypy clean
  • `pants test tests/unit/manager/repositories/auth/test_login_session_client_ip.py` — passes
  • `pants test tests/unit/manager/repositories/auth/test_login_history_client_ip.py` — passes (no regression)
  • Apply migration on a halfstack DB and confirm `login_sessions.client_ip` is populated for successful logins
  • Confirm `clientIp` appears on `myLoginSessionsV2` / `adminLoginSessionsV2` GraphQL responses after restarting the manager and Hive (Apollo Router) containers
  • Filter active sessions by `clientIp` via GraphQL (`filter: { clientIp: { equals: "…" } }`) and confirm the result

🤖 Generated with Claude Code

Mirror the BA-5733 client_ip work on the active session table:

- Add a nullable `client_ip VARCHAR(45)` column to `login_sessions` via a
  new Alembic migration chained after BA-5733's history-column migration.
- Persist the originating IP on the `login_sessions` row inside
  `create_login_session`, alongside the existing SUCCESS `login_history` row.
- Expose `clientIp` on `LoginSessionV2` (Strawberry) and the v2 REST
  `LoginSessionNode`.
- Add `client_ip` to `LoginSessionFilter` and a `CLIENT_IP` value to
  `LoginSessionOrderField` (DTO + GQL inputs); wire matching
  `LoginSessionConditions.by_client_ip_*` + `LoginSessionOrders.client_ip`
  helpers and update `LoginSessionAdapter`.
- Regenerate the supergraph / v2 schema dumps.
- Add a unit test under `tests/unit/manager/repositories/auth/` asserting
  the supplied client_ip lands on the session row.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the size:L 100~500 LoC label May 22, 2026
@github-actions github-actions Bot added area:docs Documentations comp:manager Related to Manager component comp:common Related to Common component require:db-migration Automatically set when alembic migrations are added or updated labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:common Related to Common component comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant