Role-based access control primitives for Identity Base: roles, permissions, default configuration, and effective permission resolution.
$ dotnet add package Identity.Base.RolesFull documentation lives at docs/packages/identity-base-roles/index.md. This README highlights the basics for quick reference.
Role-based access control primitives for Identity Base. Includes:
ClaimsPrincipal helpers for parsing and checking identity.permissions claims.IdentityRolesDbContext) with convenience registration helpers.// Register RBAC services and configure the provided DbContext
var rolesBuilder = services.AddIdentityRoles(
configuration,
configureDbContext: (sp, options) =>
{
var connectionString = sp.GetRequiredService<IConfiguration>().GetConnectionString("Primary")
?? throw new InvalidOperationException("ConnectionStrings:Primary must be set.");
options.UseNpgsql(connectionString); // or UseSqlServer(connectionString)
});
// Or map an existing DbContext that implements IRoleDbContext
rolesBuilder.UseDbContext<AppDbContext>();
// Map endpoints when building the app
app.MapIdentityRolesUserEndpoints();
// During startup
await app.Services.SeedIdentityRolesAsync(); // host-controlled migrations must run first
Consumers opt in explicitly; no additional tables are created unless the package is referenced and configured.