Skip to content

Create missing Plane profile on proxy auth for pre-existing users - #47

Merged
UsamaSadiq merged 5 commits into
foss-mainfrom
foss-sandbox
Jul 28, 2026
Merged

Create missing Plane profile on proxy auth for pre-existing users#47
UsamaSadiq merged 5 commits into
foss-mainfrom
foss-sandbox

Conversation

@UsamaSadiq

Copy link
Copy Markdown
Collaborator

Description

Promotes the proxy auth fix for users who have no Profile row.

Users provisioned outside Plane's signup path, such as those inserted by the JIRA migration, had no profiles row, so /api/users/me/profile/ and /api/users/me/settings/ returned 404. The web client's fetchCurrentUser bootstrap runs those fetches inside a Promise.all, so one 404 rejected the whole thing, isAuthenticated went false, and authentication-wrapper.tsx redirected back to the OAuth sign in. oauth2-proxy still held a valid session and redirected straight back, producing an infinite login loop. This affected 58 of 75 users on production.

ProxyAuthMiddleware only created a Profile when get_or_create reported created=True, so an already existing user never got one on any number of logins.

Changes:

  • Create the Profile for every user resolved through proxy auth, not only newly created ones.
  • Do the same on the already authenticated short circuit path, gated on a session flag so it costs one query per session rather than one per request. Without this, a user holding a live Django session never reaches _resolve_user and keeps looping until the session expires, which is up to 7 days.
  • Complete onboarding when the profile is not yet onboarded, so profiles created here or restored by a backfill do not strand the user on /onboarding.
  • Set the session flag after user_login to skip a redundant recheck on the next request.
  • Collapse a dead try/except ... raise in the IntegrityError handler.

Production data was already repaired out of band on 2026-07-27. This is the durable fix that stops the class of bug recurring for any externally provisioned user. It changes application code, so the plane-api image needs a rebuild and the container needs recreating.

Testing

The profile was only created for newly created users, so users
provisioned outside the signup path - such as the JIRA import - never
got one. That made /api/users/me/profile/ return 404 and bounced the
client back to the login page in a loop.
Ensure the profile on the already-authenticated short-circuit path too,
gated on a session flag, so users holding a live session are healed
instead of looping until the session expires. Collapse the now-dead
IntegrityError re-raise.
Complete onboarding for profiles healed on the short-circuit path, set
the session flag after login to avoid a redundant re-check, and cover
both behaviours with tests.
Gate onboarding on the profile's is_onboarded flag rather than on whether
this request created it, so profiles restored by an out-of-band backfill
are onboarded too.
…fill

Create missing Plane profile on proxy auth for pre-existing users
@UsamaSadiq
UsamaSadiq merged commit 462abf7 into foss-main Jul 28, 2026
8 of 9 checks passed
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.

1 participant