Interface IAuditRoleProvider
- Namespace
- Excalibur.AuditLogging
- Assembly
- Excalibur.AuditLogging.dll
Provides the current user's audit log access role.
public interface IAuditRoleProvider
Examples
public sealed class ClaimsAuditRoleProvider : IAuditRoleProvider
{
private readonly IHttpContextAccessor _httpContextAccessor;
public Task<AuditLogRole> GetCurrentRoleAsync(CancellationToken ct)
{
var user = _httpContextAccessor.HttpContext?.User;
if (user?.IsInRole("AuditAdmin") == true)
return Task.FromResult(AuditLogRole.Administrator);
if (user?.IsInRole("ComplianceOfficer") == true)
return Task.FromResult(AuditLogRole.ComplianceOfficer);
if (user?.IsInRole("SecurityAnalyst") == true)
return Task.FromResult(AuditLogRole.SecurityAnalyst);
return Task.FromResult(AuditLogRole.None);
}
}
Remarks
Consumers must implement this interface to integrate with their authorization system. Dispatch provides no default implementation - this is intentional to force explicit authorization configuration.
Implementation examples:
- Claims-based: Check ASP.NET Core role claims
- Grant-based: Use A3 or similar grant management systems
- Custom: Implement any authorization logic needed
Methods
GetCurrentRoleAsync(CancellationToken)
Gets the current user's audit log access role.
Task<AuditLogRole> GetCurrentRoleAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<AuditLogRole>
The audit log role for the current user.
Remarks
This method is called for each audit log operation. Implementations should be efficient and may cache role information for the duration of a request.