Skip to main content
Table of Contents

Class RequirePermissionAttribute

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

Declares that dispatching the decorated command/query requires the caller to hold the named permission — the fine-grained sibling of RequireRoleAttribute. Enforced by the authorizing mediator and the authorizing outbox dispatcher before the handler runs; multiple attributes on the same request are ANDed (every permission must be held).

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class RequirePermissionAttribute : Attribute
Inheritance
RequirePermissionAttribute
Inherited Members
Extension Methods

Examples

[RequirePermission("sims.read")]
public sealed record GetSimCardsQuery(Guid TenantId) : IQuery<IReadOnlyList<SimCardDto>>;

Remarks

Permission names are application vocabulary (for example "sims.read"), declared once in the application's PermissionCatalog and resolved for the current actor via the registered IPermissionResolver. Roles and permissions layer: coarse role gates (RequireRoleAttribute) and fine-grained permission gates may be combined freely on the same request type.

Fail-fast wiring: the mediator's startup validator rejects hosts that carry [RequirePermission] types without an authorizing mediator and a registered IPermissionResolver, so the attribute can never be silently ignored.

Constructors

RequirePermissionAttribute(string)

Declares that dispatching the decorated command/query requires the caller to hold the named permission — the fine-grained sibling of RequireRoleAttribute. Enforced by the authorizing mediator and the authorizing outbox dispatcher before the handler runs; multiple attributes on the same request are ANDed (every permission must be held).

public RequirePermissionAttribute(string permission)

Parameters

permission string

The permission the caller must hold.

Examples

[RequirePermission("sims.read")]
public sealed record GetSimCardsQuery(Guid TenantId) : IQuery<IReadOnlyList<SimCardDto>>;

Remarks

Permission names are application vocabulary (for example "sims.read"), declared once in the application's PermissionCatalog and resolved for the current actor via the registered IPermissionResolver. Roles and permissions layer: coarse role gates (RequireRoleAttribute) and fine-grained permission gates may be combined freely on the same request type.

Fail-fast wiring: the mediator's startup validator rejects hosts that carry [RequirePermission] types without an authorizing mediator and a registered IPermissionResolver, so the attribute can never be silently ignored.

Properties

Permission

The permission the caller must hold to dispatch the decorated request.

public string Permission { get; }

Property Value

string