ZEMA.SquareOrganization 2.1.14

dotnet add package ZEMA.SquareOrganization --version 2.1.14
                    
NuGet\Install-Package ZEMA.SquareOrganization -Version 2.1.14
                    
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="ZEMA.SquareOrganization" Version="2.1.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZEMA.SquareOrganization" Version="2.1.14" />
                    
Directory.Packages.props
<PackageReference Include="ZEMA.SquareOrganization" />
                    
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 ZEMA.SquareOrganization --version 2.1.14
                    
#r "nuget: ZEMA.SquareOrganization, 2.1.14"
                    
#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 ZEMA.SquareOrganization@2.1.14
                    
#: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=ZEMA.SquareOrganization&version=2.1.14
                    
Install as a Cake Addin
#tool nuget:?package=ZEMA.SquareOrganization&version=2.1.14
                    
Install as a Cake Tool

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 OrgId claim
  • 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 SquareOrgLoginDataValidator as a source-only validator)
  • Localizable error messages via OrgMessages constants
  • 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 with OrganizationId
  • ISquareOrganizationLoginData — extends login data with OrganizationId and OrganizationIdentification
  • The OrgId claim 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 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. 
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
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
Loading failed