Skip to content

fix(auth): support Auth0 role claim namespace variations#15

Merged
mpaulosky merged 1 commit into
devfrom
squad/13-boromir-merge-notes
Apr 19, 2026
Merged

fix(auth): support Auth0 role claim namespace variations#15
mpaulosky merged 1 commit into
devfrom
squad/13-boromir-merge-notes

Conversation

@mpaulosky

Copy link
Copy Markdown
Owner

Overview

Fixes admin role display in Profile and NavMenu when Auth0 uses production namespace.

Changes

  • RoleClaimsHelper: Added namespace inference to detect role claims ending with role or roles
  • GetEffectiveRoleClaimTypes(): Infers namespaced role claim types from authenticated user's actual claims
  • appsettings.json: Updated to include production Auth0 namespace https://articlesite.com/roles
  • Tests: Comprehensive coverage of namespace variations and inference behavior

Technical Details

Auth0 exposes roles under https://articlesite.com/roles in production, but the app only recognized https://myblog/roles. Now the app automatically detects any claim type ending in 'role' or 'roles' and treats it as a role claim.

Verification

  • Release build passed ✓
  • All 4 files staged with meaningful changes ✓
  • Namespace inference enabled for Profile.razor and NavMenu ✓

Copilot AI review requested due to automatic review settings April 19, 2026 01:46

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

Updates Auth0 role-claim handling so the app can recognize roles from varying Auth0 namespaces (not just the previously configured one), restoring correct admin-role behavior in Profile and Blazor AuthorizeView.

Changes:

  • Added role-claim type inference in RoleClaimsHelper by treating any claim type whose tail segment is role/roles as a role claim.
  • Updated Web configuration to include the production Auth0 roles namespace.
  • Expanded unit test coverage to validate namespaced claim inference and updated Profile-related tests to use the production namespace.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Unit.Tests/Security/RoleClaimsHelperTests.cs Adds coverage for IsRoleClaimType and verifies inference/normalization across namespaced role claim types.
tests/Unit.Tests/Features/UserManagement/ProfileTests.cs Updates test principal to emit roles using the production namespace claim type.
src/Web/appsettings.json Adds https://articlesite.com/roles to configured Auth0:RoleClaimTypes.
src/Web/Security/RoleClaimsHelper.cs Implements role-claim namespace inference and uses it for AddRoleClaims and GetRoles.
.squad/decisions/inbox/boromir-pr12-followups.md Removes an inbox decision file that is now consolidated elsewhere.
.squad/decisions.md Adds documentation describing the role-claim namespace inference decision (but currently duplicates an existing entry).
.squad/agents/ralph/history.md Records orchestration/actions taken around prior PR thread resolution and merge.
.squad/agents/legolas/history.md Records frontend validation of the admin-role UI behavior after the fix.
.squad/agents/gandalf/history.md Records security review notes from prior PR work.
.squad/agents/frodo/history.md Records security-side implementation summary for role claim normalization.
.squad/agents/boromir/history.md Records ruleset/merge-blocker findings and post-merge sync procedures from prior PRs.

Comment thread .squad/decisions.md
…ations

- Add IsRoleClaimType() to detect role claims ending with 'role' or 'roles'
- GetEffectiveRoleClaimTypes() now infers namespaced role claims from identity
- AddRoleClaims() and GetRoles() use inferred claim types automatically
- appsettings.json includes production Auth0 namespace
- Tests cover Auth0 namespace variations and inference logic

Fixes #13: Profile.razor and NavMenu now display admin role correctly even when Auth0 uses different namespace

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mpaulosky
mpaulosky force-pushed the squad/13-boromir-merge-notes branch from 1629eef to de754c3 Compare April 19, 2026 01:58
@github-actions

Copy link
Copy Markdown
Contributor

Summary

Summary
Generated on: 04/19/2026 - 01:59:44
Coverage date: 04/19/2026 - 01:59:16 - 04/19/2026 - 01:59:32
Parser: MultiReport (4x Cobertura)
Assemblies: 4
Classes: 35
Files: 34
Line coverage: 65.3% (474 of 725)
Covered lines: 474
Uncovered lines: 251
Coverable lines: 725
Total lines: 2054
Branch coverage: 67.2% (179 of 266)
Covered branches: 179
Total branches: 266
Method coverage: Feature is only available for sponsors
Tag: 29_24618604858

Coverage

AppHost - 0%
Name Line Branch
AppHost 0% ****
Program 0%
Domain - 93.4%
Name Line Branch
Domain 93.4% 50%
Domain.Abstractions.Result 95% 50%
Domain.Abstractions.Result`1 75% 50%
MyBlog.Domain.Entities.BlogPost 100%
ServiceDefaults - 0%
Name Line Branch
ServiceDefaults 0% 0%
Microsoft.Extensions.Hosting.Extensions 0% 0%
Web - 69.5%
Name Line Branch
Web 69.5% 72.5%
MyBlog.Web.Components.Layout.MainLayout 100%
MyBlog.Web.Components.Layout.NavMenu 82.8% 71.4%
MyBlog.Web.Components.Pages.Error 100% 75%
MyBlog.Web.Components.Routes 0% 0%
MyBlog.Web.Components.Shared.RedirectToLogin 100%
MyBlog.Web.Data.BlogDbContext 100%
MyBlog.Web.Data.BlogPostDto 100%
MyBlog.Web.Data.BlogPostMappings 100%
MyBlog.Web.Data.MongoDbBlogPostRepository 100% 100%
MyBlog.Web.Features.BlogPosts.Create.Create 75% 50%
MyBlog.Web.Features.BlogPosts.Create.CreateBlogPostCommand 100%
MyBlog.Web.Features.BlogPosts.Create.CreateBlogPostHandler 100%
MyBlog.Web.Features.BlogPosts.Delete.ConfirmDeleteDialog 100% 100%
MyBlog.Web.Features.BlogPosts.Delete.DeleteBlogPostCommand 100%
MyBlog.Web.Features.BlogPosts.Delete.DeleteBlogPostHandler 100%
MyBlog.Web.Features.BlogPosts.Edit.Edit 88% 75%
MyBlog.Web.Features.BlogPosts.Edit.EditBlogPostCommand 100%
MyBlog.Web.Features.BlogPosts.Edit.EditBlogPostHandler 84% 90%
MyBlog.Web.Features.BlogPosts.Edit.GetBlogPostByIdQuery 100%
MyBlog.Web.Features.BlogPosts.List.GetBlogPostsHandler 100% 100%
MyBlog.Web.Features.BlogPosts.List.Index 86.8% 84.6%
MyBlog.Web.Features.UserManagement.AssignRoleCommand 100%
MyBlog.Web.Features.UserManagement.ManageRoles 90.4% 75%
MyBlog.Web.Features.UserManagement.Profile 97.2% 82%
MyBlog.Web.Features.UserManagement.RemoveRoleCommand 100%
MyBlog.Web.Features.UserManagement.RoleDto 100%
MyBlog.Web.Features.UserManagement.UserManagementHandler 0% 0%
MyBlog.Web.Features.UserManagement.UserWithRolesDto 100%
MyBlog.Web.Security.RoleClaimsHelper 91.8% 91.1%
Program 0% 0%

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
Domain 0% 0% 38
Web 0% 0% 333
ServiceDefaults 0% 0% 18
Domain 0% 0% 38
Web 0% 0% 333
ServiceDefaults 0% 0% 18
AppHost 0% 100% 1
Domain 43% 0% 38
Web 6% 5% 333
ServiceDefaults 0% 0% 18
AppHost 0% 100% 1
Domain 43% 0% 38
Web 6% 5% 333
ServiceDefaults 0% 0% 18
Domain 93% 50% 38
Web 64% 65% 333
ServiceDefaults 0% 0% 18
Domain 93% 50% 38
Web 64% 65% 333
ServiceDefaults 0% 0% 18
Summary 23% (1000 / 4310) 22% (358 / 1656) 2336

@mpaulosky
mpaulosky merged commit c5cf359 into dev Apr 19, 2026
6 checks passed
@mpaulosky
mpaulosky deleted the squad/13-boromir-merge-notes branch April 19, 2026 02:00
mpaulosky added a commit that referenced this pull request Apr 19, 2026
…asset manifest

- Merged 4 decisions from inbox into .squad/decisions.md:
  - Decision #12: Merged-Branch Guard — guidance-only, defer automation
  - Decision #13: Release Guidance Fit for MyBlog
  - Decision #14: Delete non-fit imported assets
  - (Decision #15 reflected via DELETED-ASSETS.md manifest)

- Updated agent histories with Milestone 3 coordination summary:
  - Aragorn: Release guidance finalized & asset disposition approved
  - Boromir: Merged-branch guard evidence review & secondary skills sync
  - Pippin: Deleted-assets manifest publication

- Published .squad/decisions/DELETED-ASSETS.md as canonical reference
  for future contributors (post-build-validation, static-config-pattern,
  building-protection, release-process-base, release-issuetracker)

- Confirmed asset disposition:
  - Deleted: 5 non-fit skills/playbooks
  - Retained: microsoft-code-reference (rewrite queued, backlog)
  - Active: release-process (MyBlog-specific routing)

- Removed merged inbox files (4x decision submissions)

- Milestone 3 roadmap complete; Sprint 3 cleanup ready for execution

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.

2 participants