Skip to content

fix(auth): derive SSO display name from email local-part#23

Open
hunzlahmalik wants to merge 1 commit into
foss-mainfrom
fix/sso-display-name-from-email-local-part
Open

fix(auth): derive SSO display name from email local-part#23
hunzlahmalik wants to merge 1 commit into
foss-mainfrom
fix/sso-display-name-from-email-local-part

Conversation

@hunzlahmalik
Copy link
Copy Markdown

Summary

  • Drop the x-auth-request-user header read in the ForwardAuth middleware — oauth2-proxy was putting the Cognito sub UUID into that header, so newly-provisioned SSO users landed with a UUID (e.g. 892ae5ac-0021-…) as their User.name.
  • Use the email local-part as the display name. The middleware already fell back to this value when the header was absent; we're promoting that fallback to the only source.
  • Consolidate the two SSO-provision tests in authentication.test.ts into one — after the fix, the x-auth-request-user-absent branch is the only branch. Also update the AUTH_TYPE JSDoc in env.ts to drop the stale mention of X-Auth-Request-User.

Existing users with UUID name values are not auto-corrected — the middleware does not re-sync the field on subsequent logins. A backfill is out of scope here.

Test plan

  • yarn test server/middlewares/authentication.test.ts passes
  • yarn tsc --noEmit passes
  • Devstack end-to-end: a fresh Cognito user whose cognito:username is the bare sub UUID lands at https://foss-wiki.local.moneta.dev with User.name = email local-part, not the UUID
  • SELECT email, name FROM users ORDER BY "createdAt" DESC LIMIT 5; reflects the new behavior

🤖 Generated with Claude Code

oauth2-proxy was putting the Cognito sub UUID into x-auth-request-user
instead of a human-readable username, so newly-provisioned SSO users
landed with a UUID as their User.name. Drop the header read in the
ForwardAuth middleware and use the email local-part instead — the
same value both apps already fell back to when the header was absent;
we're promoting that fallback to the only source.

Existing users with UUID names are not auto-corrected: the middleware
does not re-sync the name field on subsequent logins.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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