fix(profile): fall back to authenticated email claims on /profile#279
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🏗️ PR Added to Squad Triage QueueThis PR has been labeled with Next steps:
|
Test Results Summary341 tests +10 340 ✅ +10 19s ⏱️ ±0s Results for commit 318ae7a. ± Comparison against base commit 5b1828f. This pull request removes 16 and adds 26 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
This PR fixes /profile email rendering by expanding claim fallbacks (beyond the framework-mapped email claim), explicitly requesting the Auth0 email scope, and making the Auth0 Management API configuration resolution compatible with both new and legacy config keys.
Changes:
- Request
openid profile emailscopes for Auth0 web login to improve availability of direct email claims. - Update
Profile.razorto derive an email address from multiple legitimate claim shapes (includingpreferred_usernameand email-typed claim tails). - Add tests that lock in the email scope requirement and cover direct + fallback email-claim shapes; update Auth0 Management settings resolution to support legacy keys.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Web/Program.cs |
Adds explicit email scope to Auth0 web auth configuration. |
src/Web/Features/UserManagement/Profile.razor |
Adds robust email-claim fallback logic (including parsing multi-value claims). |
src/Web/Features/UserManagement/UserManagementHandler.cs |
Reads Auth0 Management settings from both new and legacy configuration keys; adds optional audience support. |
tests/Architecture.Tests/ProfileEmailAuthContractTests.cs |
Adds contract test asserting email scope is requested in Program.cs. |
tests/Web.Tests.Bunit/Features/ProfileTests.cs |
Adds bUnit regressions for direct email claim and preferred_username fallback. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #279 +/- ##
==========================================
- Coverage 86.57% 86.14% -0.44%
==========================================
Files 44 44
Lines 1043 1097 +54
Branches 116 132 +16
==========================================
+ Hits 903 945 +42
- Misses 96 100 +4
- Partials 44 52 +8
🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Aragorn lead gate: merge-ready.
No further blockers from lead review. Safe to squash-merge. |
Summary
Fix the profile email display when the authenticated principal exposes a legitimate email through alternate claim forms, and keep the Auth0 management client compatible with both current and legacy configuration keys.
Working as Sam (Backend / .NET). Ralph coordinated final delivery.
What changed
src/Web/Program.csemailscope alongsideopenid profileso Auth0 can issue the direct email claim when available.src/Web/Features/UserManagement/Profile.razoremailclaim handling and falls back to alternate legitimate authenticated email claim forms before rendering the profile card.tests/Architecture.Tests/ProfileEmailAuthContractTests.csemailscope requirement inProgram.cs.tests/Web.Tests.Bunit/Features/ProfileTests.cspreferred_username.src/Web/Features/UserManagement/UserManagementHandler.csAuth0Management:*and legacyAuth0:ManagementApi*keys, treats whitespace as missing, and preserves explicit configuration and HTTP failure behavior.Validation
tests/Architecture.Tests/Architecture.Tests.csproj --filter ProfileEmailAuthContractTests: 1 passedtests/Web.Tests.Bunit/Web.Tests.Bunit.csproj --filter ProfileTests: 7 passedtests/Web.Tests/Web.Tests.csproj --filter UserManagementHandlerTests: 16 passedtests/Web.Tests/Web.Tests.csproj: 148 passed, 0 failedsrc/AppHost/AppHost.csproj/test/login?role=Admin/profilerenderstest@example.comin the live appCloses #278