fix(auth): skip the per-request bunyip userinfo round-trip (PMS-723) #487
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-713-skip-userinfo-per-request"
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?
PMS-723: skip the per-request bunyip
/oauth2/userinforound-tripSplit from PMS-713 (the "clicking Refresh freezes the UI" report). A browser Performance capture proved the freeze is not a Dioxus render issue: ~3.6s total with only ~16ms scripting and an idle main thread on a 1-ticket dataset - pure I/O wait.
Root cause
The Bunyip-as-OP Resource-Server path (
src/modules/auth/middleware.rs) called bunyip's/oauth2/userinfoover the network on every authenticated request.ensure_user_from_bunyipran unconditionally after the at+jwt verified (JWKS is cached, so that part was fine) and always awaitedverifier.userinfo(bearer)- no "user already exists" short-circuit. userinfo is only needed to JIT-provision a first-sight user, back-fill a user stuck in the legacy default tenant, or match a pending invite. For an already-provisioned, placed user it's a wasted round-trip on every request, so the dashboard (which fires/reports/dashboard,/tickets,/time-entries,/projects, ...) stalled for seconds. App-wide latency, not a UI bug.Fix
bunyip_userinfo_neededgates the fetch: resolve the user bysubfrom local state and skip the hop when they exist, are placed in a real tenant, and have no pending invite (matched on their local verified email). Only fetch on first-sight JIT, stuck-in-default back-fill, or a pending invite.place_bunyip_useralready resolves an existing user from local state withNoneemail/name while still running the PMS-698 principal gate and the role reconcile, so the fast path passesNone. All the checks in the gate are local DB reads - cheap next to the network round-trip they remove.Behavior preserved
Tests
tests/bunyip_login.rs: gate skips for an existing placed user; still fetches for first-sight and for a pending-invite match; andplace_bunyip_userresolves an existing user with no userinfo (fast path) keeping tenant + cached name. Fullbunyip_login(20),bunyip_principal_gate+auth(36+2) suites pass;clippy -D warningsandfmtclean.Not yet verified live; the acceptance item on PMS-723 is confirming the dashboard Refresh no longer stalls after deploy.