Table of Contents

Class ScopeProxy<T>

Namespace
Tharga.Team.Service
Assembly
Tharga.Team.Service.dll

DispatchProxy that intercepts service method calls and enforces RequireScopeAttribute by checking scope claims on the current principal (resolved via ITeamPrincipalAccessor, so it works for both HTTP and interactive Blazor callers). Methods without the attribute throw InvalidOperationException (fail-closed). Also verifies a TeamKey claim is present. Logs audit entries when IAuditLogger is available.

public class ScopeProxy<T> : DispatchProxy where T : class

Type Parameters

T
Inheritance
ScopeProxy<T>
Inherited Members

Methods

Create(T, IHttpContextAccessor, ServiceScopeKind, IAuditLogger)

Overload for HTTP-only callers — adapts an IHttpContextAccessor to the default accessor.

public static T Create(T target, IHttpContextAccessor httpContextAccessor, ServiceScopeKind scopeKind, IAuditLogger auditLogger = null)

Parameters

target T
httpContextAccessor IHttpContextAccessor
scopeKind ServiceScopeKind
auditLogger IAuditLogger

Returns

T

Create(T, IHttpContextAccessor, ServiceScopeKind, IAuditLogger, AuditMode)

As above, with the host's default audit mode for methods whose attribute does not declare one.

public static T Create(T target, IHttpContextAccessor httpContextAccessor, ServiceScopeKind scopeKind, IAuditLogger auditLogger, AuditMode defaultAuditMode)

Parameters

target T
httpContextAccessor IHttpContextAccessor
scopeKind ServiceScopeKind
auditLogger IAuditLogger
defaultAuditMode AuditMode

Returns

T

Remarks

An overload rather than an optional parameter on the existing signature: a call site bakes the whole optional-argument list into the emitted call, so adding one would break every assembly already compiled against this method.

Create(T, ITeamPrincipalAccessor, ServiceScopeKind, IAuditLogger)

public static T Create(T target, ITeamPrincipalAccessor principalAccessor, ServiceScopeKind scopeKind, IAuditLogger auditLogger = null)

Parameters

target T
principalAccessor ITeamPrincipalAccessor
scopeKind ServiceScopeKind

Deliberately required. A default would pick an authorization policy on the caller's behalf, which is how a service ends up enforcing something other than what its author assumed.

auditLogger IAuditLogger

Returns

T

Create(T, ITeamPrincipalAccessor, ServiceScopeKind, IAuditLogger, AuditMode)

As above, with the host's default audit mode for methods whose attribute does not declare one.

public static T Create(T target, ITeamPrincipalAccessor principalAccessor, ServiceScopeKind scopeKind, IAuditLogger auditLogger, AuditMode defaultAuditMode)

Parameters

target T
principalAccessor ITeamPrincipalAccessor
scopeKind ServiceScopeKind
auditLogger IAuditLogger
defaultAuditMode AuditMode

Returns

T

Remarks

An overload rather than an optional parameter on the existing signature: a call site bakes the whole optional-argument list into the emitted call, so adding one would break every assembly already compiled against this method.

Invoke(MethodInfo, object[])

Whenever any method on the generated proxy type is called, this method is invoked to dispatch control.

protected override object Invoke(MethodInfo targetMethod, object[] args)

Parameters

targetMethod MethodInfo

The method the caller invoked.

args object[]

The arguments the caller passed to the method.

Returns

object

The object to return to the caller, or null for void methods.