Table of Contents

Class GrantAdministration

Namespace
MailFathom.Application.Access.Grants
Assembly
MailFathom.Application.dll

What an administrator does to roles, groups, and role assignments, and how a user's grant is explained.

public sealed class GrantAdministration
Inheritance
GrantAdministration
Inherited Members

Remarks

Reading is AdminRead and writing is AdminRolesWrite, each held at a scope covering what the act names: the group, the user, and the scope an assignment is made at. Roles are the deployment's vocabulary, so any holder of the reading grant reads them and only the root — the writing grant held over the deployment — defines one. A group in no organization and an assignment at the deployment scope are the deployment's as well. A target outside the caller's scope is answered exactly as one that does not exist, so an organization's administrator learns nothing about anybody else's groups, users, or assignments by naming them.

Nobody grants more than they hold, or wider than they hold it. Assigning a role needs every name it lists held by the writer at a scope covering the assignment's; joining a group is receiving its assignments, so adding a member needs every name those assignments give held at a scope covering each of them. A mail name's scope is never read, so it need only be held. A name with no operation below the deployment scope grants nothing at a narrower one, so giving it there widens nobody and is not asked about. Revoking an assignment and ending a membership need only the coverage, because taking a grant away widens nobody — and the store refuses the one that would leave the deployment with no root. See ADR 0012.

A role listing a pattern holds whatever a later release publishes in the pattern's reach, so no check of what its giver holds today bounds what it gives. Assigning such a role, and adding a member to a group an assignment gives one to, therefore needs the root on top of everything above, whatever scope the write names: the root already may write any name into any role, so it is the one grant a widening role cannot carry past.

The escalation check reads the role's list, the group's assignments, and where each user belongs a moment before the write, and a concurrent change to any of them is not re-read inside it. Each of those changes is itself an act this class bounds by its writer's grant — a role's list is the root's alone to write — so the window lets nobody widen past what somebody holding the reach to widen them already decided.

Every write that changed something is recorded through IGrantAuditor after it committed, naming the administrator it was admitted as.

Constructors

GrantAdministration(AccessAuthorization, IGrantStore, IUserCredentialStore, IGrantAuditor, TimeProvider)

Initializes the administration over one deployment's roles, groups, and assignments.

Methods

AddGroupMemberAsync(Guid, UserId, CancellationToken)

Makes a user a member of a group, which gives them every assignment the group holds.

AssignAsync(Guid, AssignmentPrincipal, AssignmentScope, CancellationToken)

Gives a role to a user or a group at a scope, under an identifier this deployment mints.

CreateGroupAsync(string?, Guid?, CancellationToken)

Records a group under an identifier this deployment mints.

CreateRoleAsync(string?, RolePermissions, CancellationToken)

Records a role under an identifier this deployment mints.

DeleteGroupAsync(Guid, CancellationToken)

Removes a group nothing is assigned to, and its memberships with it.

DeleteRoleAsync(Guid, CancellationToken)

Removes a role nobody is assigned.

ExplainUserGrantAsync(UserId, CancellationToken)

Explains why one user holds each permission they hold within the caller's scope, and what each of their credentials keeps of it.

FindNameRefusal(string?)

Reports why a written role or group name cannot be recorded, or that it can.

ReadAssignmentsAsync(AdministrativeListingQuery, CancellationToken)

Reads one page of the role assignments the caller's scopes cover.

ReadGroupMembersAsync(Guid, AdministrativeListingQuery, CancellationToken)

Reads one page of the members of one group the caller's scope covers.

ReadGroupsAsync(AdministrativeListingQuery, CancellationToken)

Reads one page of the groups the caller's scopes cover.

ReadRolesAsync(AdministrativeListingQuery, CancellationToken)

Reads one page of the roles this deployment holds.

RemoveGroupMemberAsync(Guid, UserId, CancellationToken)

Ends a user's membership of a group, which takes every assignment the group holds away from them.

RenameGroupAsync(Guid, string?, CancellationToken)

Replaces the name an operator reads a group by.

RenameRoleAsync(Guid, string?, CancellationToken)

Replaces the name an operator reads a role by.

ReplaceRolePermissionsAsync(Guid, RolePermissions, CancellationToken)

Replaces the whole list of permissions a role grants, which reaches everybody it is assigned to at their next request.

RevokeAsync(Guid, CancellationToken)

Revokes one assignment.