{"id":23882021,"url":"https://github.com/274188a/blazor-auth0-dotnet9","last_synced_at":"2025-09-09T11:31:32.221Z","repository":{"id":270650232,"uuid":"911036485","full_name":"274188A/Blazor-Auth0-dotnet9","owner":"274188A","description":"Experiments with Auth0","archived":false,"fork":false,"pushed_at":"2025-01-03T09:38:00.000Z","size":771,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-03T10:25:55.709Z","etag":null,"topics":["aspire","auth0","auth0-jwt","blazor","dotnet9","monolith-architecture"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/274188A.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-02T05:18:27.000Z","updated_at":"2025-01-03T09:40:46.000Z","dependencies_parsed_at":"2025-01-03T10:26:11.803Z","dependency_job_id":null,"html_url":"https://github.com/274188A/Blazor-Auth0-dotnet9","commit_stats":null,"previous_names":["274188a/blazor-auth0-aspire-dotnet9","274188a/blazor-auth0-dotnet9"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/274188A%2FBlazor-Auth0-dotnet9","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/274188A%2FBlazor-Auth0-dotnet9/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/274188A%2FBlazor-Auth0-dotnet9/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/274188A%2FBlazor-Auth0-dotnet9/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/274188A","download_url":"https://codeload.github.com/274188A/Blazor-Auth0-dotnet9/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232418688,"owners_count":18519934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspire","auth0","auth0-jwt","blazor","dotnet9","monolith-architecture"],"created_at":"2025-01-04T02:36:49.013Z","updated_at":"2025-01-04T02:36:49.773Z","avatar_url":"https://github.com/274188A.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blazor App with Aspire and Auth0 Integration\n\nThis is a **very simple Blazor app** that integrates **Aspire** and **Auth0** for identity management. The app uses Auth0 to define roles, which are added to the identity token using a **post-login event trigger**.\n\n## Key Features\n\n- **Roles Defined in Auth0**: Roles are set up in Auth0 and injected into the identity token via a post-login trigger.\n- **Mapping Auth0 Roles**: The C# code translates Auth0 role claims into standard roles for use within the application.\n\n### Example of Role Claim Mapping Using Trigger Post-Login\n\n```javascript\nexports.onExecutePostLogin = async (event, api) =\u003e {\n  const roleClaim = 'https://blazorserverapp.local';\n  if (event.authorization) {\n    api.idToken.setCustomClaim(${roleClaim}/roles, event.authorization.roles);\n  }\n};\n```\n\n### Code To Map Auth0 Roles to Standard Roles\n\nThe application contains C# logic to map the Auth0 roles:\n\n```csharp\n// Add claim mapping logic to include custom roles\nbuilder.Services.Configure\u003cOpenIdConnectOptions\u003e(Auth0Constants.AuthenticationScheme, options =\u003e\n{\n    options.TokenValidationParameters = new TokenValidationParameters\n    {\n        RoleClaimType = $\"{audience}/roles\" // Map custom role claim\n    };\n\n    options.Events = new OpenIdConnectEvents\n    {\n        OnTokenValidated = context =\u003e\n        {\n            if (context.Principal?.Identity is ClaimsIdentity identity)\n            {\n                // Map custom roles to standard role claims\n                var roleClaims = identity.FindAll($\"{audience}/roles\").ToList();\n                foreach (var roleClaim in roleClaims)\n                {\n                    identity.AddClaim(new Claim(ClaimTypes.Role, roleClaim.Value));\n                }\n            }\n\n            return Task.CompletedTask;\n        }\n    };\n});\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F274188a%2Fblazor-auth0-dotnet9","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F274188a%2Fblazor-auth0-dotnet9","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F274188a%2Fblazor-auth0-dotnet9/lists"}