Interface IAuthorizationProvider
- Namespace
- Stratara.Abstractions.Authorization
- Assembly
- Stratara.Abstractions.dll
Provides role-membership checks for the authorizing mediator + command-outbox-dispatcher
decorators. Implementations typically read from HttpContext.User, a JWT claim set,
or a tenant-scoped identity service.
public interface IAuthorizationProvider
- Extension Methods
Examples
Minimal ASP.NET Core implementation that reads from the current
HttpContext.User:
public sealed class HttpContextAuthorizationProvider(IHttpContextAccessor accessor) : IAuthorizationProvider
{
public Task<bool> IsInRoleAsync(string role, CancellationToken cancellationToken = default) =>
Task.FromResult(accessor.HttpContext?.User?.IsInRole(role) ?? false);
}
builder.Services
.AddHttpContextAccessor()
.AddAuthorizingMediator<HttpContextAuthorizationProvider>();
Methods
IsInRoleAsync(string, CancellationToken)
Check whether the current caller holds role.
Task<bool> IsInRoleAsync(string role, CancellationToken cancellationToken = default)
Parameters
rolestringThe role name to check.
cancellationTokenCancellationTokenPropagated by the caller.