forked from gongxuegit/tiku-backend.net
feat(security): complete capability messaging workflows
This commit is contained in:
@@ -82,6 +82,22 @@ public sealed class TenantExecutionScope(
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(request.Caller);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(request.Reason);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(request.CorrelationId);
|
||||
if (request.TargetTenantId is null && !request.IsGlobal)
|
||||
{
|
||||
throw new ArgumentException("System scope requires a target tenant or an explicit global declaration.", nameof(request));
|
||||
}
|
||||
if (request.TargetTenantId is not null && request.IsGlobal)
|
||||
{
|
||||
throw new ArgumentException("A tenant-targeted system scope cannot also be global.", nameof(request));
|
||||
}
|
||||
if (request.IsGlobal && request.CallerType is SystemScopeCallerType.Worker or SystemScopeCallerType.PublicQuestionBank)
|
||||
{
|
||||
throw new ArgumentException("Worker and public question bank scopes must target a tenant.", nameof(request));
|
||||
}
|
||||
if (!Enum.IsDefined(request.CallerType))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(request), "Unknown system scope caller type.");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task WriteAuditAsync(
|
||||
@@ -105,6 +121,7 @@ public sealed class TenantExecutionScope(
|
||||
request.Caller,
|
||||
request.Reason,
|
||||
request.CorrelationId,
|
||||
request.IsGlobal,
|
||||
startedAt,
|
||||
elapsedMilliseconds,
|
||||
failureType
|
||||
|
||||
Reference in New Issue
Block a user