feat(users): PR11.1 backend - user filters, last login, auth method - #22
Merged
Conversation
Extends GET /platform/users with organization_id/status/role filters (all additive, backward compatible) and adds two new persisted fields to the user directory: last_login_at and authentication_method. Both are written from exactly one place, generate_tokens -- the shared choke point every login flow (password/oauth/sso/license) already calls -- so every flow stays in sync by construction rather than repeating the write at each call site. Never written on token refresh, which continues a session rather than starting one. No historical data is fabricated: a user who predates this migration, or has never logged in since, shows null end-to-end. No new permission, no authorization changes -- every endpoint here still gates on the existing manage_all_orgs permission.
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.
Objective
Backend half of PR11.1 (Enterprise User Management Enhancement). Companion frontend PR: OmniBioAI/omnibioai-control-center#11.
Per the discovery doc from this same effort (
omnibioai-control-center/docs/admin-console-pr11-identity-findings.md), this extends the existing/platform/usersdirectory rather than introducing anything new — no new permission, no new authorization model.Changes
1.
GET /platform/usersfilters — three new, independent, optional query params:organization_id,status,role. All backward compatible (omitted = unfiltered, exactly as before).rolemeans different things depending on whetherorganization_idis also present, matching how this codebase already models roles as two separate catalogs:organization_id: matches the caller's role within that org (membership_roles).user_roles).Still gated by the same
manage_all_orgspermission as before — no new permission introduced.2.
users.last_login_at/users.authentication_method(migration0012_user_login_metadata, additive, nullable, no backfill — a user with no login since this migration has honestnull, never a fabricated value).Both fields are written from exactly one place:
auth_service.generate_tokens, the shared choke point every login flow (password/oauth/sso/license) already calls. This means every flow stays in sync by construction rather than repeating the write at 7 different call sites acrossroutes_auth.py/routes_oauth.py/routes_sso.py/routes_license.py. Deliberately not inbuild_user_claims(whichrotate_refresh_tokenalso calls) — a token refresh continues an existing session, it must not look like a new login.authentication_methoduses a narrower, admin-console-facing vocabulary (password/oauth/oidc/unknown) than the JWTauth_methodclaim (password/oauth/sso/license), which is unchanged:sso→oidcfor display,license→unknown(no dedicated slot for it in the PR11.1 spec).Both new fields are added to
PlatformUserSummary(list) andPlatformUserDetailOut(detail).Test results
Full suite: 536 passed. New coverage: filter combinations (org/status/role, independently and combined), backward-compatibility when all three are omitted, login-metadata persistence across all three real login flows (password in
test_platform_users_api.py, SSO intest_sso_login.py, consumer OAuth intest_oauth.py), null-for-never-logged-in.Non-goals (per spec)
No MFA, domain verification, SAML, SCIM, billing, usage metering, audit center, or session management — all future PR11.x work.
🤖 Generated with Claude Code