fix(auth): seed first_name/last_name defaults on bunyip JIT user upsert #60
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
psa-systems/mokosh-server!60
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/jit-user-name-defaults"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
ensure_user_from_bunyip JIT-inserts a row into public.users on first
sight of a new sub. upsert_user_from_oidc built that INSERT without
first_name or last_name; the schema marks both NOT NULL, so every
JIT insert errored with 23502, ensure_user_from_bunyip returned None,
auth_middleware fell through to legacy verifiers (which reject
bunyip's EdDSA at+jwt as InvalidAlgorithm) and returned 401.
Symptom in the wild: every authenticated /api/v1/* endpoint 401s for
any bunyip-OP-authed user who hadn't already been inserted into
mokosh-server's users table by some other path (the legacy SSO flow,
a previous direct-mokosh login, etc). The mokosh-apps tickets and
contacts pages were both running on the seeded-demo-rows fallback;
deleting the fallback in feat/crm-ops surfaced the bug for the first
time on the contacts page, but it was breaking every authed call.
Fix: derive synthetic first_name/last_name from the email local-part
when inserting. yousif@niceguyit.biz becomes ('Yousif', ''), and
firstname.lastname@... becomes ('Firstname', 'Lastname'). The
@unresolved.invalid placeholder used when /oauth2/userinfo can't
resolve email falls back to ('User', ''). Users can overwrite their
name from Settings; a future userinfo refresh path can also overwrite
this default with the real name claim if bunyip ever ships one.
The synthetic_name_from_email helper is gated behind
#[cfg(feature = "server")] to match the existing module-level
helpers around it.