Nedo.AspNet.Authentication.Auth0
2.0.9
dotnet add package Nedo.AspNet.Authentication.Auth0 --version 2.0.9
NuGet\Install-Package Nedo.AspNet.Authentication.Auth0 -Version 2.0.9
<PackageReference Include="Nedo.AspNet.Authentication.Auth0" Version="2.0.9" />
<PackageVersion Include="Nedo.AspNet.Authentication.Auth0" Version="2.0.9" />
<PackageReference Include="Nedo.AspNet.Authentication.Auth0" />
paket add Nedo.AspNet.Authentication.Auth0 --version 2.0.9
#r "nuget: Nedo.AspNet.Authentication.Auth0, 2.0.9"
#:package Nedo.AspNet.Authentication.Auth0@2.0.9
#addin nuget:?package=Nedo.AspNet.Authentication.Auth0&version=2.0.9
#tool nuget:?package=Nedo.AspNet.Authentication.Auth0&version=2.0.9
Nedo.AspNet.Authentication.Auth0
Auth0 as the canonical token issuer (JWT-bearer pattern). Validates Auth0-issued JWTs and auto-maps Auth0's namespace-prefixed custom claims + RBAC permissions to ASP.NET Core's ClaimTypes.Role.
Install
dotnet add package Nedo.AspNet.Authentication.Auth0
Quickstart
using Nedo.AspNet.Authentication.Auth0;
builder.Services.AddAuth0(opts =>
{
opts.Domain = builder.Configuration["Auth0:Domain"]!; // "my-tenant.auth0.com"
opts.Audience = builder.Configuration["Auth0:Audience"]!; // "https://api.example.com"
});
builder.Services.AddAuthorization();
builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped<IAuthContext, AuthContext>();
var app = builder.Build();
app.UseAuthentication();
app.UseNedoAuthContext();
app.UseAuthorization();
app.MapGet("/admin", (IAuthContext auth) => auth.UserId)
.RequireAuthorization(p => p.RequireRole("admin"));
Claims auto-mapping
Auth0 prefixes custom claims with a namespace URL (e.g. https://my-app.example.com/roles) to comply with OIDC. The defaults map the common shapes:
| Auth0 claim | Mapped to |
|---|---|
https://{namespace}/roles: ["admin"] |
ClaimTypes.Role |
permissions: ["read:reports", "write:reports"] (Auth0 RBAC) |
permission claims |
email_verified |
left as-is |
sub |
ClaimTypes.NameIdentifier |
Configure your namespace via opts.RolesClaimNamespace = "https://my-app.example.com/roles"; if you use a non-default URL pattern.
Auth0 Action / Rule prerequisites
To get roles and permissions in the access token, configure them on the Auth0 side:
- Roles — add an Action that copies
event.user.app_metadata.roles(or your role source) ontoevent.accessTokenunder your namespace claim:exports.onExecutePostLogin = async (event, api) => { const namespace = 'https://my-app.example.com/'; api.accessToken.setCustomClaim(`${namespace}roles`, event.user.app_metadata?.roles ?? []); }; - Permissions — enable RBAC + "Add Permissions in the Access Token" on the API in the Auth0 dashboard.
Docs
docs/04-identity-providers.md.
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Nedo.AspNet.Authentication (>= 2.0.9)
- Nedo.AspNet.Authentication.Claims (>= 2.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.