Class AccessAuthorization
- Namespace
- MailFathom.Application.Access
- Assembly
- MailFathom.Application.dll
What a use case asks before it does the work it was reached for.
public sealed class AccessAuthorization
- Inheritance
-
AccessAuthorization
- Inherited Members
Remarks
The transport refuses what it can refuse cheaply, and this is the authority. An entrypoint added later — a rule action, a worker, a command, a second protocol — reaches a use case without passing any middleware, so a check that lived only there is one the new entrypoint forgets. Asking here is what makes the answer a property of the operation instead of a property of the route somebody happened to arrive by.
Each method admits exactly one kind of principal and refuses every other, including a principal that holds more. RequireProcessIdentity() in particular is not "a caller with everything granted": a principal that could be admitted by holding a permission would be reachable by whoever an operator granted that permission to, which is the opposite of what work no caller requested runs under.
Every method refuses when the work was reached under no principal, so an entrypoint that never stated what admitted it fails rather than defaulting to permitted.
RequireUser() is the one method about whose mail rather than about what may be done to it. It is asked beside a permission rather than instead of one, because the two axes are independent: no permission names a user, and a grant however broad still reaches the mail of the one user the work was admitted for.
Some members report instead of refusing, for a boundary composing an answer per caller rather than performing an
operation for one, and none decides anything of its own. Each Permits member answers exactly what its
Require counterpart would have refused — Permits(MailFathomPermission) for RequirePermission(MailFathomPermission),
PermitsAtAnyScope(MailFathomPermission) for RequirePermissionAtAnyScope(MailFathomPermission), and the PermitsOverAsync
overloads, PermitsOver(MailFathomPermission, AdministrativeTarget), and CoveredMailAccountsAsync(MailFathomPermission, IReadOnlyCollection<MailAccountId>, CancellationToken) for
the RequirePermissionOverAsync overloads — so the
transport and the use case cannot come to disagree about what holding a permission means.
HoldsOnlyBelowDeployment(MailFathomPermission) answers what a refusal of an operation admitted only at the deployment
scope says on top of naming the permission: that the caller holds it, but only over an organization or a user.
ScopesOf(MailFathomPermission) is what a listing answers within, since a listing never refuses over a scope.
Constructors
- AccessAuthorization(IAuthorizedPrincipalSource)
Initializes the authorization over the principal of the unit of work in hand, placing no target.
- AccessAuthorization(IAuthorizedPrincipalSource, IAdministrativeTargets)
Initializes the authorization over the principal of the unit of work in hand, placing what an operation names.
Properties
- PrincipalIdentity
Gets what the work in hand was admitted as, or null where it was reached under no principal.
Methods
- CoveredMailAccountsAsync(MailFathomPermission, IReadOnlyCollection<MailAccountId>, CancellationToken)
Answers which of several mail accounts the caller holds one named capability over, placing them in one read.
- HoldsOnlyBelowDeployment(MailFathomPermission)
Reports whether the caller reaching this work holds one administrative capability only below the deployment, which a refusal of an operation admitted only at the deployment scope says on top of naming the permission.
- Permits(MailFathomPermission)
Answers the same question RequirePermission(MailFathomPermission) asks, for a boundary that has to decide rather than refuse.
- PermitsAtAnyScope(MailFathomPermission)
Answers whether the caller holds one named capability at any scope, for a transport that leaves the target to the operation.
- PermitsOver(MailFathomPermission, AdministrativeTarget)
Answers whether the caller holds one named capability over a target the operation placed itself.
- PermitsOverAsync(MailFathomPermission, UserId, CancellationToken)
Answers whether the caller holds one named capability over one user, for a boundary that has to decide rather than refuse.
- PermitsOverAsync(MailFathomPermission, MailAccountId, CancellationToken)
Answers whether the caller holds one named capability over one mail account, for a boundary that has to decide rather than refuse.
- PermitsOverScopeAsync(MailFathomPermission, AssignmentScope, CancellationToken)
Answers whether the caller holds one named capability at a scope covering everything another scope covers.
- RequireAnyPermission(MailFathomPermission, MailFathomPermission)
Requires that an admitted caller holding either of two named capabilities is what reached this use case.
- RequirePermission(MailFathomPermission)
Requires that an admitted caller holding one named capability is what reached this use case.
- RequirePermissionAtAnyScope(MailFathomPermission)
Requires that an admitted caller holding one named capability at any scope is what reached this use case, for an operation that learns its target only by reading it.
- RequirePermissionOverAsync(MailFathomPermission, UserId, CancellationToken)
Requires that an admitted caller holding one named capability over one user is what reached this use case.
- RequirePermissionOverAsync(MailFathomPermission, MailAccountId, CancellationToken)
Requires that an admitted caller holding one named capability over one mail account is what reached this use case.
- RequirePermissionOverTheDeployment(MailFathomPermission)
Requires one named capability over the whole deployment, for an act only that scope admits reached through an operation that otherwise names a target.
- RequireProcessIdentity()
Requires that this use case was reached as work no caller requested.
- RequireSignedCapability()
Requires that a capability this deployment signed is what reached this use case.
- RequireUser()
Requires that the work in hand is being done for one user, and answers which.
- ScopesOf(MailFathomPermission)
Reports the scopes the caller holds one capability at, which is what a listing answers within.