Class AuditingUserManagementServiceDecorator
Decorator that wraps IUserManagementService and logs audit entries for user administration: per-user verification (with outcome), bulk verification (one summary entry), and deletion (with team count and directory result). The directory-only listing is a read with no side effect and is not audited, consistent with team enumeration.
public class AuditingUserManagementServiceDecorator : IUserManagementService
- Inheritance
-
AuditingUserManagementServiceDecorator
- Implements
- Inherited Members
Constructors
AuditingUserManagementServiceDecorator(IUserManagementService, CompositeAuditLogger, IHttpContextAccessor)
public AuditingUserManagementServiceDecorator(IUserManagementService inner, CompositeAuditLogger auditLogger, IHttpContextAccessor httpContextAccessor)
Parameters
innerIUserManagementServiceauditLoggerCompositeAuditLoggerhttpContextAccessorIHttpContextAccessor
Methods
DeleteUserAsync(string, bool, CancellationToken)
Delete a user: removes the user from every team and deletes the user record (audited).
With deleteFromDirectory the user is also deleted from the external directory;
a directory failure does not roll back the local delete — it is reported on the result.
public Task<UserDeleteResult> DeleteUserAsync(string userKey, bool deleteFromDirectory = false, CancellationToken cancellationToken = default)
Parameters
userKeystringdeleteFromDirectoryboolcancellationTokenCancellationToken
Returns
GetDirectoryOnlyUsersAsync(CancellationToken)
List directory users that have no matching local user (matched by directory id, falling back to email), streamed as directory pages arrive.
public IAsyncEnumerable<DirectoryUser> GetDirectoryOnlyUsersAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
GetOwnedTeamsAsync(string, CancellationToken)
public Task<IReadOnlyList<ITeam>> GetOwnedTeamsAsync(string userKey, CancellationToken cancellationToken = default)
Parameters
userKeystringcancellationTokenCancellationToken
Returns
Remarks
A read that runs when a delete confirmation opens, so it is not audited — logging it would record an entry for looking at a dialog the operator may then cancel. The delete it precedes is audited.
SetUserDisabledAsync(string, bool, CancellationToken)
public Task SetUserDisabledAsync(string userKey, bool disabled, CancellationToken cancellationToken = default)
Parameters
userKeystringdisabledboolcancellationTokenCancellationToken
Returns
Remarks
Both directions, under distinct actions — disable is a containment, enable is a
decision to let the person back in. One entry keyed on a boolean would make "who re-enabled this"
a query rather than a reading. The refusal to disable oneself is audited as a failure too: an
administrator repeatedly trying it is worth seeing.
SetUserNameAsync(string, string, CancellationToken)
public Task<UserNameChangeResult> SetUserNameAsync(string userKey, string name, CancellationToken cancellationToken = default)
Parameters
userKeystringnamestringcancellationTokenCancellationToken
Returns
Remarks
The directory outcome is recorded rather than just the local write: a rename that succeeded here and failed there is the case someone will later need to explain, and it is invisible otherwise.
VerifyAllAsync(CancellationToken)
Verify all local users against the external directory, streamed as results arrive.
public IAsyncEnumerable<UserVerificationResult> VerifyAllAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
VerifyUserAsync(string, CancellationToken)
Verify a local user against the external directory. When the user resolves via email fallback, the found directory id is persisted on the user (relink).
public Task<DirectoryVerificationResult> VerifyUserAsync(string userKey, CancellationToken cancellationToken = default)
Parameters
userKeystringcancellationTokenCancellationToken