Skip to main content
Table of Contents

Class PermissionCatalog

Namespace
Stratara.Abstractions.Authorization
Assembly
Stratara.Abstractions.dll

The application's permission vocabulary plus its role→permission grants, declared in code at startup and registered as a singleton. The catalog is the single source of what permission names exist; role grants map coarse roles (tenant-scoped membership roles or global platform roles alike) onto sets of fine-grained permissions.

public sealed class PermissionCatalog
Inheritance
PermissionCatalog
Inherited Members
Extension Methods

Examples

services.AddPermissionCatalog(catalog =>
{
    catalog.Add("sims.read", "sims.write", "billing.read");
    catalog.GrantToRole("TenantAdmin", "sims.read", "sims.write", "billing.read");
    catalog.GrantToRole("Support", "sims.read");
});

Remarks

Declaration is strict by design: granting an undeclared permission throws, so a typo in a grant surfaces at startup instead of silently never matching. Reads are lock-free; build the catalog completely during service registration and treat it as immutable afterwards.

Properties

All

Every permission name declared in the catalog.

public IReadOnlyCollection<string> All { get; }

Property Value

IReadOnlyCollection<string>

Methods

Add(params string[])

Declares one or more permission names. Redeclaring an existing name is a no-op.

public void Add(params string[] permissions)

Parameters

permissions string[]

The permission names to declare.

Exceptions

ArgumentException

A name is null, empty, or whitespace.

Contains(string)

Checks whether the permission name is declared in the catalog.

public bool Contains(string permission)

Parameters

permission string

The permission name to check.

Returns

bool

true when declared.

GetRolePermissions(string)

Gets the permissions granted to the role; empty for roles without grants.

public IReadOnlySet<string> GetRolePermissions(string role)

Parameters

role string

The role whose grants to read.

Returns

IReadOnlySet<string>

The granted permission set.

GrantToRole(string, params string[])

Grants declared permissions to a role; cumulative across calls for the same role.

public void GrantToRole(string role, params string[] permissions)

Parameters

role string

The role receiving the grants.

permissions string[]

Previously declared permission names.

Exceptions

ArgumentException

The role name is empty, or a permission was not declared via Add(params string[]) first (strictness catches grant typos at startup).