Class CurrentPrincipalAccessor
- Namespace
- Cratis.Arc.Authorization
- Assembly
- Cratis.Arc.Core.dll
Represents an implementation of ICurrentPrincipalAccessor and ICurrentPrincipalOverride that resolves the current principal from the HTTP request when one is in progress, falling back to a server-side override otherwise.
public class CurrentPrincipalAccessor : ICurrentPrincipalAccessor, ICurrentPrincipalOverride
- Inheritance
-
CurrentPrincipalAccessor
- Implements
- Inherited Members
- Extension Methods
Constructors
CurrentPrincipalAccessor(IHttpRequestContextAccessor)
Represents an implementation of ICurrentPrincipalAccessor and ICurrentPrincipalOverride that resolves the current principal from the HTTP request when one is in progress, falling back to a server-side override otherwise.
public CurrentPrincipalAccessor(IHttpRequestContextAccessor httpRequestContextAccessor)
Parameters
httpRequestContextAccessorIHttpRequestContextAccessorThe IHttpRequestContextAccessor used to detect an in-progress HTTP request and read its principal.
Properties
Current
Gets the ClaimsPrincipal that is currently executing — the HTTP request principal while a request is in progress, otherwise the principal established by a server-side execution scope, or null when neither is present.
public ClaimsPrincipal? Current { get; }
Property Value
Methods
BeginScope(ClaimsPrincipal)
Begins a scope that overrides the current principal for server-side execution.
public IDisposable BeginScope(ClaimsPrincipal principal)
Parameters
principalClaimsPrincipalThe ClaimsPrincipal to execute as.
Returns
- IDisposable
An IDisposable that restores the previous principal when disposed.
Remarks
The override is ignored while an HTTP request is in progress — the request principal always wins — so a server-side scope can never influence authorization of an HTTP-origin command.