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
                    
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="Lewee.Auth.Domain" Version="0.40.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lewee.Auth.Domain" Version="0.40.3" />
                    
Directory.Packages.props
<PackageReference Include="Lewee.Auth.Domain" />
                    
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 Lewee.Auth.Domain --version 0.40.3
                    
#r "nuget: Lewee.Auth.Domain, 0.40.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 Lewee.Auth.Domain@0.40.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=Lewee.Auth.Domain&version=0.40.3
                    
Install as a Cake Addin
#tool nuget:?package=Lewee.Auth.Domain&version=0.40.3
                    
Install as a Cake Tool

Lewee.Auth.Domain

Domain models for application-owned authentication and multi-tenant authorization data.

Features

  • Independent User and Tenant aggregate roots
  • Globally unique external user identities
  • Zero-or-more tenant memberships per user
  • Idempotent tenant assignment and removal
  • A direct IsSiteAdministrator flag on User, independent of tenant or role
  • A globally-unique Role catalog, 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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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