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
TResourceThe type of the resource to authorize against.
TIdThe 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.