Skip to content

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

Merged
UsamaSadiq merged 3 commits into
foss-sandboxfrom
fix/sso-display-name-from-email-local-part
Jun 4, 2026
Merged

fix(auth): derive SSO display name from email local-part#23
UsamaSadiq merged 3 commits into
foss-sandboxfrom
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 profile.fullname.
  • 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.
  • Update the two x-auth-request-auto-register-* tests: drop the now-unused header from the request maps, and add an explicit assertion that :fullname equals the email local-part.

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

Test plan

  • pnpm run test from backend/ passes (focused: backend-tests.http-middleware-test)
  • Devstack end-to-end: a fresh Cognito user whose cognito:username is the bare sub UUID lands at https://foss-design.local.moneta.dev with profile.fullname = email local-part, not the UUID
  • SELECT email, fullname FROM profile ORDER BY created_at 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 profile fullname. 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 profiles with UUID fullnames are not auto-corrected: the
middleware does not re-sync :fullname on subsequent logins.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@hunzlahmalik hunzlahmalik changed the base branch from foss-main to foss-sandbox June 2, 2026 11:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the ForwardAuth (x-auth-request-*) authentication middleware so that newly auto-provisioned SSO users always get a stable, human-readable profile.fullname derived from the email local-part (instead of sometimes inheriting an upstream UUID via x-auth-request-user). It also updates the corresponding middleware tests to reflect the new behavior.

Changes:

  • Stop reading x-auth-request-user for display-name derivation; always use the email local-part when auto-registering.
  • Update the auto-register tests to no longer set x-auth-request-user, and assert :fullname is the email local-part.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
backend/src/app/http/auth_request.clj Removes dependence on x-auth-request-user and uses email local-part for auto-registered profile display names.
backend/test/backend_tests/http_middleware_test.clj Updates auto-register middleware tests to match the new display-name derivation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/src/app/http/auth_request.clj Outdated
Comment thread backend/test/backend_tests/http_middleware_test.clj Outdated
…name

Address review on #23:

- Middleware: pass nil instead of a pre-split local-part into
  get-or-register-profile, so that function is the only place deriving
  the display name (from the resolved email). Removes the duplicate
  split and the drift risk between the two derivation paths.

- Test: re-add x-auth-request-user to the auto-register request with a
  Cognito-sub-style UUID and keep asserting :fullname is the email
  local-part. This is the actual regression guard for the reported bug;
  the prior test dropped the header entirely, so it no longer proved the
  middleware ignores it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@UsamaSadiq UsamaSadiq merged commit 90f1a7f into foss-sandbox Jun 4, 2026
4 of 14 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.

3 participants