Interface ISystemExecution

Namespace
Cratis.Arc.Authorization
Assembly
Cratis.Arc.Core.dll

Defines a system for executing commands from server-side / background code as a trusted system actor.

public interface ISystemExecution
Extension Methods

Remarks

Command authorization normally reads the principal from the current HTTP request. Server-side callers (reactors, hosted services, sagas, or one command orchestrating another) have no HTTP request, so any command carrying AuthorizeAttribute or RolesAttribute is denied. Entering a scope established through this system makes an authenticated principal ambiently available for the duration of the scope, so such commands can execute as a trusted system actor. The established principal is consulted only when there is no HTTP request context, so it can never influence authorization of an HTTP-origin command.

Methods

As(ClaimsPrincipal)

Establishes a scope that executes as the specified ClaimsPrincipal.

IDisposable As(ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The ClaimsPrincipal to execute as.

Returns

IDisposable

An IDisposable that restores the previous execution context when disposed.

AsSystem(params string[])

Establishes a scope that executes as an authenticated system actor carrying the given roles.

IDisposable AsSystem(params string[] roles)

Parameters

roles string[]

The roles the system actor holds. When empty, the actor satisfies AuthorizeAttribute but no RolesAttribute.

Returns

IDisposable

An IDisposable that restores the previous execution context when disposed.