Table of Contents

Interface IIdentifyResource<TResource, TId>

Namespace
Trellis.Authorization
Assembly
Trellis.Authorization.dll

Declares that this message carries a typed resource identifier that can be extracted for resource-based authorization. Implement alongside IAuthorizeResource<TResource> to use a SharedResourceLoaderById<TResource, TId> instead of a per-command ResourceLoaderById<TMessage, TResource, TId>.

public interface IIdentifyResource<TResource, out TId>

Type Parameters

TResource

The type of the resource to authorize against.

TId

The identifier type (e.g., OrderId).

Extension Methods

Examples

public record CancelOrderCommand(OrderId OrderId)
    : ICommand<Result<Unit>>, IAuthorizeResource<Order>, IIdentifyResource<Order, OrderId>
{
    public OrderId GetResourceId() => OrderId;
    public IResult Authorize(Actor actor, Order order) => ...;
}

Methods

GetResourceId()

Extracts the resource identifier from this message.

TId GetResourceId()

Returns

TId

The typed resource identifier.