Identity.Base.Organizations 0.9.3

dotnet add package Identity.Base.Organizations --version 0.9.3
                    
NuGet\Install-Package Identity.Base.Organizations -Version 0.9.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Identity.Base.Organizations" Version="0.9.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Identity.Base.Organizations" Version="0.9.3" />
                    
Directory.Packages.props
<PackageReference Include="Identity.Base.Organizations" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Identity.Base.Organizations --version 0.9.3
                    
#r "nuget: Identity.Base.Organizations, 0.9.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Identity.Base.Organizations@0.9.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Identity.Base.Organizations&version=0.9.3
                    
Install as a Cake Addin
#tool nuget:?package=Identity.Base.Organizations&version=0.9.3
                    
Install as a Cake Tool

Identity Base Organizations

For the canonical documentation (installation, endpoints, extension points) see docs/packages/identity-base-organizations/index.md. The README provides a quick-start snapshot.

Identity.Base.Organizations layers organization management on top of the core Identity Base and RBAC packages. It provides EF Core entities, services, hosted infrastructure, and minimal API endpoints so any host can manage organizations, memberships, and organization-scoped roles without custom scaffolding.

Features

  • Organization aggregate (Organization, OrganizationMetadata) with per-tenant slug/display name uniqueness.
  • Membership service with role assignments and paged user/admin queries; active organization selection is explicit and client-side.
  • Organization-specific role catalog and claim formatter that augments Identity Base permission claims with organization context.
  • Hosted seed services that bootstrap default roles (OrgOwner, OrgManager, OrgMember) once your migrations have been applied.
  • Minimal API modules for CRUD, membership management, role management, and user-facing endpoints.
  • Core-builder hooks for model/seed/claim/scope customization plus an organizations-builder lifecycle-listener registration.

Installation

1. Add the package

dotnet add package Identity.Base.Organizations

2. Register services

Add the organizations services after AddIdentityBase (and optionally AddIdentityRoles) in Program.cs:

using Identity.Base.Extensions;
using Identity.Base.Organizations.Extensions;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

Action<IServiceProvider, DbContextOptionsBuilder> configureDbContext = (sp, options) =>
{
    var connectionString = sp.GetRequiredService<IConfiguration>().GetConnectionString("Primary")
        ?? throw new InvalidOperationException("ConnectionStrings:Primary must be set.");

    options.UseNpgsql(connectionString); // or UseSqlServer(connectionString)
};

var identityBuilder = builder.Services.AddIdentityBase(
    builder.Configuration,
    builder.Environment,
    configureDbContext: configureDbContext);
builder.Services.AddIdentityRoles(builder.Configuration, configureDbContext);
var organizationsBuilder = builder.Services.AddIdentityBaseOrganizations(configureDbContext);

var app = builder.Build();
app.UseApiPipeline(appBuilder => appBuilder.UseSerilogRequestLogging());
app.UseOrganizationContextFromHeader();
app.MapApiEndpoints();
app.MapIdentityRolesUserEndpoints();
app.MapIdentityBaseOrganizationEndpoints();
await app.RunAsync();

AddIdentityBaseOrganizations no longer auto-configures DbContexts. Provide the delegate shown above or register OrganizationDbContext yourself before calling the extension.

3. Apply migrations

Generate and apply migrations from your host project targeting the provider you selected:

dotnet ef migrations add InitialOrganizations --context OrganizationDbContext
dotnet ef database update --context OrganizationDbContext

4. Seed default roles

OrganizationRoleSeeder creates the default system roles after your host has applied migrations. Register additional callbacks if you need to extend the seed pipeline:

identityBuilder.AfterOrganizationSeed(async (sp, ct) =>
{
    // e.g. provision billing metadata, assign baseline memberships, etc.
});

5. Customize the model

Use ConfigureOrganizationModel to add indexes or shadow properties:

identityBuilder.ConfigureOrganizationModel(modelBuilder =>
{
    modelBuilder.Entity<Organization>().HasIndex(org => org.CreatedAtUtc);
});

API surface

Method & Route Description Permission
/admin/organizations Platform administration: paged organization CRUD plus nested members, roles, permissions, and invitations. admin.organizations.*
/users/me/organizations Self-service organization creation/list/detail plus nested member, role, permission, and invitation management. Authenticated plus user.organizations.*
GET /invitations/{code} Return a public invitation preview without invitee email or role IDs. Anonymous
POST /invitations/claim Accept an invitation for the authenticated matching user. Authenticated

Default organization roles (Owner/Manager/Member) currently receive only the user-scoped (user.organizations.*) permissions. Create a separate role with admin.organizations.* permissions if you need a platform-wide organization administrator.

Active organization context

Tokens issued by Identity Base now include an org:memberships claim listing all organization IDs for the signed-in user. Add the middleware in your pipeline:

app.UseOrganizationContextFromHeader();

Then send the X-Organization-Id header on scoped requests. The middleware validates the caller still belongs to that organization and loads the metadata into IOrganizationContextAccessor; admin /admin/organizations routes intentionally ignore the header and remain global. If membership changes, refresh tokens so org:memberships and permission claims stay up to date.

Authorization is enforced through the Identity Base RBAC package. The default IOrganizationScopeResolver verifies the caller is a member of the target organization; override it (or IPermissionClaimFormatter) via the builder extensions to compose tenant-specific or elevated administrator rules.

Options

  • OrganizationOptions
    • SlugMaxLength, DisplayNameMaxLength
    • MetadataMaxBytes, MetadataMaxKeyLength, MetadataMaxValueLength
  • OrganizationRoleOptions
    • NameMaxLength, DescriptionMaxLength
    • Default role names (OwnerRoleName, ManagerRoleName, MemberRoleName)

Bind or override using the standard options pattern:

builder.Services.Configure<OrganizationOptions>(builder.Configuration.GetSection("Organizations"));

Configuration notes

  • Auto-binding: AddIdentityBaseOrganizations binds options by default
    • OrganizationsOrganizationOptions
    • Organizations:RoleOptionsOrganizationRoleOptions
    • Organizations:AuthorizationOrganizationAuthorizationOptions
  • Role definition overrides: defaults are merged with config; definitions are de-duplicated by name (case-insensitive) and the last entry wins. This lets you override built-in OrgOwner/OrgManager/OrgMember definitions without producing duplicate roles.

Extensibility

identityBuilder
    .ConfigureOrganizationModel(modelBuilder => { /* custom EF configuration */ })
    .AfterOrganizationSeed(async (sp, ct) => { /* custom seeding */ })
    .AddOrganizationClaimFormatter<CustomFormatter>()
    .AddOrganizationScopeResolver<CustomScopeResolver>();

organizationsBuilder
    .AddOrganizationLifecycleListener<CustomOrganizationLifecycleListener>();

IOrganizationLifecycleListener covers create/update/archive/restore, invitation create/revoke/accept, and membership add/update/remove operations. Legacy creation/update/archive listener helpers remain compatibility shims but are obsolete for new integrations.

Testing

Run the solution tests to execute the organizations unit suite alongside the existing Identity Base coverage:

dotnet test Identity.sln

License

MIT, consistent with the rest of the Identity Base OSS packages.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.3 135 7/27/2026
0.9.2 90 7/26/2026
0.8.10 157 6/6/2026
0.8.8 160 4/6/2026
0.8.6 1,220 3/4/2026
0.8.5 115 3/4/2026
0.8.4 705 2/9/2026
0.7.17 177 1/26/2026
0.7.16 128 1/20/2026
0.7.15 144 1/6/2026
0.7.12 128 12/30/2025
0.7.9 407 12/17/2025
0.7.7 236 12/3/2025
0.7.6 239 11/26/2025
0.7.5 373 11/14/2025
0.7.4 352 11/13/2025
0.7.3 339 11/10/2025
0.7.2 255 11/9/2025
0.7.1 201 11/9/2025
0.6.3 192 11/8/2025
Loading failed