Class ActorProviderExtensions
- Namespace
- Trellis.Authorization
- Assembly
- Trellis.Authorization.dll
Provides required actor access for callers with established actor presence and stable provider resolution.
public static class ActorProviderExtensions
- Inheritance
-
ActorProviderExtensions
- Inherited Members
Methods
RequireActorAsync(IActorProvider, CancellationToken)
Resolves the current actor, throwing if the caller's actor-presence invariant is broken.
public static Task<Actor> RequireActorAsync(this IActorProvider actorProvider, CancellationToken cancellationToken = default)
Parameters
actorProviderIActorProviderThe provider used to resolve the actor.
cancellationTokenCancellationTokenToken forwarded to the provider.
Returns
Remarks
Use only when actor presence is already guaranteed and the provider returns stable identity and authorization state throughout the operation. This method performs another provider lookup; it does not retrieve a snapshot captured by an authorization behavior. Authorization alone does not establish provider stability. When resolution can change, both authorization and the handler must use the same scoped caching provider, configured before either lookup. This method does not authenticate, check permissions, enforce stability, or cache the actor. It calls the provider once per invocation. For ordinary unauthenticated requests, use GetCurrentActorAsync(CancellationToken) and handle absence as Error.AuthenticationRequired instead. Provider exceptions and cancellation propagate unchanged.
Exceptions
- ArgumentNullException
actorProvideris null.- InvalidOperationException
The provider returned no actor.