Skip to main content
Table of Contents

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>();

Remarks

The example is the request-side shape. A command the Orleans execution model records is authorized again where it runs — possibly on another silo, resumed after a crash — from the session recorded with it and without a web request; a host that records commands needs a provider that answers from ISessionContextProvider, such as the membership provider, or every resumed command is refused.

Methods

IsInRoleAsync(string, CancellationToken)

Check whether the current caller holds role.

Task<bool> IsInRoleAsync(string role, CancellationToken cancellationToken = default)

Parameters

role string

The role name to check.

cancellationToken CancellationToken

Propagated by the caller.

Returns

Task<bool>

true if the caller is in the role; false otherwise.