Lewee.Auth.Domain
0.40.3
dotnet add package Lewee.Auth.Domain --version 0.40.3
NuGet\Install-Package Lewee.Auth.Domain -Version 0.40.3
<PackageReference Include="Lewee.Auth.Domain" Version="0.40.3" />
<PackageVersion Include="Lewee.Auth.Domain" Version="0.40.3" />
<PackageReference Include="Lewee.Auth.Domain" />
paket add Lewee.Auth.Domain --version 0.40.3
#r "nuget: Lewee.Auth.Domain, 0.40.3"
#:package Lewee.Auth.Domain@0.40.3
#addin nuget:?package=Lewee.Auth.Domain&version=0.40.3
#tool nuget:?package=Lewee.Auth.Domain&version=0.40.3
Lewee.Auth.Domain
Domain models for application-owned authentication and multi-tenant authorization data.
Features
- Independent
UserandTenantaggregate roots - Globally unique external user identities
- Zero-or-more tenant memberships per user
- Idempotent tenant assignment and removal
- A direct
IsSiteAdministratorflag onUser, independent of tenant or role - A globally-unique
Rolecatalog, defined by a site administrator and assignable to any tenant's memberships - Idempotent role assignment/removal on
TenantMembership, supporting multiple roles per membership - Domain events for user, tenant, membership, and role lifecycle changes
Dependencies
- Lewee.Domain for aggregate roots, entities, domain events, and specifications
Usage
Create users independently of tenants, then manage memberships separately:
var tenant = Tenant.Create("STORE1", "Store One", correlationId);
var user = User.Create(externalUserId, correlationId);
user.AssignToTenant(tenant.Id, correlationId);
user.RemoveFromTenant(tenant.Id, correlationId);
Tenant codes are unique secondary identifiers with a maximum length of 10 characters. Tenant names have a maximum length of 200 characters, and external user IDs have a maximum length of 100 characters.
A site administrator is identified directly by User.IsSiteAdministrator, independent of any tenant or role. There
is no public domain method to set this flag - given how rarely it changes, the setter is internal and exposed via
InternalsVisibleTo to trusted callers (e.g. a seeder) that set it directly, rather than via a command.
Roles are defined once, globally, by a site administrator, and can be assigned to any tenant's memberships:
var role = Role.Create("MANAGER", "Manager", correlationId);
user.AssignRole(tenant.Id, role.Id, correlationId);
user.RemoveRole(tenant.Id, role.Id, correlationId);
A single TenantMembership can hold zero, one, or many roles at once. Role codes are globally unique (not scoped to
a tenant), with a maximum length matching Role.FieldLengths.Code; role names have a maximum length matching
Role.FieldLengths.Name and are not required to be unique.
Main Types
| Type | Purpose |
|---|---|
Tenant |
Identifies an organization by ID, unique code, and name |
User |
Represents an external identity independently of tenant membership; exposes IsSiteAdministrator |
TenantMembership |
Associates a user with a tenant, and zero or more roles |
Role |
A globally-unique, site-administrator-defined role that any tenant may assign to its members |
UserByExternalIdSpecification |
Finds a user by globally unique external identity |
TenantCreatedEvent |
Records tenant creation, including its code and name |
TenantMembershipCreatedEvent |
Records assignment of a user to a tenant |
TenantMembershipRemovedEvent |
Records removal of a user from a tenant |
RoleDefinedEvent |
Records definition of a new role |
TenantRoleAssignedEvent |
Records assignment of a role to a tenant membership |
TenantRoleRemovedEvent |
Records removal of a role from a tenant membership |
Persistence and application orchestration are provided by Lewee.Auth.Infrastructure.Data and Lewee.Auth.Application.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Lewee.Domain (>= 0.40.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Lewee.Auth.Domain:
| Package | Downloads |
|---|---|
|
Lewee.Auth.Application
Package Description |
|
|
Lewee.Auth.Infrastructure.Data
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.40.3 | 52 | 11/22/2026 |