Class ScopeProxy<T>
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
targetThttpContextAccessorIHttpContextAccessorscopeKindServiceScopeKindauditLoggerIAuditLogger
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
targetThttpContextAccessorIHttpContextAccessorscopeKindServiceScopeKindauditLoggerIAuditLoggerdefaultAuditModeAuditMode
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
targetTprincipalAccessorITeamPrincipalAccessorscopeKindServiceScopeKindDeliberately 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.
auditLoggerIAuditLogger
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
targetTprincipalAccessorITeamPrincipalAccessorscopeKindServiceScopeKindauditLoggerIAuditLoggerdefaultAuditModeAuditMode
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
targetMethodMethodInfoThe method the caller invoked.
argsobject[]The arguments the caller passed to the method.