ZEMA.SquareOrganization
2.1.14
dotnet add package ZEMA.SquareOrganization --version 2.1.14
NuGet\Install-Package ZEMA.SquareOrganization -Version 2.1.14
<PackageReference Include="ZEMA.SquareOrganization" Version="2.1.14" />
<PackageVersion Include="ZEMA.SquareOrganization" Version="2.1.14" />
<PackageReference Include="ZEMA.SquareOrganization" />
paket add ZEMA.SquareOrganization --version 2.1.14
#r "nuget: ZEMA.SquareOrganization, 2.1.14"
#:package ZEMA.SquareOrganization@2.1.14
#addin nuget:?package=ZEMA.SquareOrganization&version=2.1.14
#tool nuget:?package=ZEMA.SquareOrganization&version=2.1.14
ZEMA.SquareOrganization.Lib
A .NET 8 library that extends ZEMA.Square.Lib to add multi-tenant organization management to any ASP.NET Core application built on the ZEMA Square platform.
Installation
dotnet add package ZEMA.SquareOrganization.Lib --version 2.1.*
Requirements
- .NET 8.0
- ZEMA.Square.Lib 2.1.x
Features
- Multi-organization (multi-tenant) data isolation via JWT
OrgIdclaim - User ↔ organization associations with role-based access control
- Soft-delete (archivable) and owner-managed rule base classes
- 190+ countries, states, time zones, languages, and regions — seeded automatically
- EF Core DbContext with full entity configuration
- AutoMapper profiles and FluentValidation integration (includes
SquareOrgLoginDataValidatoras a source-only validator) - Localizable error messages via
OrgMessagesconstants - Google authentication support
- REST API endpoints for switching organization context
Getting Started
1. Register services
builder.Services.IdentityOrganizationService<
TUser,
TLoginData,
TOrganization,
TDbContext>(options =>
{
// configure identity options
});
This registers ASP.NET Core Identity, adds an "Organization" authorization policy that requires the OrgId claim, and wires up AutoMapper profiles.
2. Seed reference data
await SeedOrganizationBase.SeedDataAsync<TDbContext>(
serviceProvider,
createDefaultUser: async (userManager) => { /* create super user */ },
createDefaultOrg: async (context) => { /* create default org */ }
);
Populates countries, states, time zones, languages, and regions on first run.
3. Protect routes
Add the "Organization" policy to any controller or endpoint that must be scoped to an organization:
[Authorize(Policy = "Organization")]
[ApiController]
public class MyController : ControllerBase { ... }
4. Scope business rules to the current organization
Inherit from the appropriate base rule. The base class reads OrgId from the HTTP context and automatically filters all queries and enforces the organization on writes.
// Entity with Guid PK and soft-delete
public class ProductRule : OrganizationArchivableBaseGuidRule<
TDbContext, TOrganization, TLoggedUser, Product, ProductM>
{
public ProductRule(IServiceProvider sp) : base(sp) { }
}
Rule hierarchy:
OrganizationBaseRule<>
├── OrganizationArchivableBaseRule<> — soft-delete entities
│ ├── OrganizationArchivableBaseGuidRule<>
│ ├── OrganizationArchivableBaseStringRule<>
│ └── OrganizationArchivableBaseValueRule<>
└── OrganizationOwnerBaseRule<> — owner-managed entities
├── OrganizationOwnerBaseGuidRule<>
├── OrganizationOwnerBaseStringRule<>
└── OrganizationOwnerBaseValueRule<>
Built-in API Endpoints
OrganizationSquareAccountController<> provides:
| Method | Route | Description |
|---|---|---|
GET |
/user_organizations |
List all organizations for the authenticated user |
POST |
/set_user_organization |
Switch the current organization context |
Security Model
ISquareOrganizationLoggedUser— extends the base logged-user withOrganizationIdISquareOrganizationLoginData— extends login data withOrganizationIdandOrganizationIdentification- The
OrgIdclaim is propagated through the JWT token and used by every rule to isolate data per tenant
Dependencies
| Package | Version |
|---|---|
| ZEMA.Square.Lib | 2.1.92 |
| AutoMapper | 16.1.1 |
| FluentValidation.AspNetCore | 11.3.1 |
| Google.Apis.Auth | 1.73.0 |
| Newtonsoft.Json | 13.0.4 |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- AutoMapper (>= 16.1.1)
- FluentValidation.AspNetCore (>= 11.3.1)
- Google.Apis.Auth (>= 1.73.0)
- Newtonsoft.Json (>= 13.0.4)
- ZEMA.Square.Lib (>= 2.1.92)
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 |
|---|---|---|
| 2.1.14 | 99 | 5/29/2026 |
| 2.1.13 | 101 | 5/27/2026 |
| 2.1.12 | 97 | 5/25/2026 |
| 2.1.11 | 97 | 5/20/2026 |
| 2.1.10 | 89 | 5/18/2026 |
| 2.1.9 | 86 | 5/18/2026 |
| 2.0.4 | 97 | 5/18/2026 |
| 2.0.3 | 100 | 4/22/2026 |
| 2.0.2 | 96 | 4/21/2026 |
| 2.0.1 | 100 | 4/21/2026 |
| 2.0.0 | 95 | 4/21/2026 |
| 1.2.21 | 108 | 3/12/2026 |
| 1.2.20 | 109 | 2/5/2026 |
| 1.2.19 | 112 | 2/3/2026 |
| 1.2.18 | 109 | 2/2/2026 |
| 1.2.17 | 111 | 1/30/2026 |
| 1.2.16 | 113 | 1/29/2026 |
| 1.2.15 | 112 | 1/26/2026 |
| 1.2.14 | 105 | 1/26/2026 |
| 1.2.13 | 114 | 1/26/2026 |