Class AuthorizedPrincipal
- Namespace
- MailFathom.Application.Access
- Assembly
- MailFathom.Application.dll
Whoever a unit of work is running for, whose mail it is acting on, and what they were granted.
public sealed class AuthorizedPrincipal
- Inheritance
-
AuthorizedPrincipal
- Inherited Members
Remarks
This is the whole of what the application layer learns about the outside of a request. It carries the identity the work was admitted under, the user it is acting for where there is one, and the permissions that identity holds, and nothing else: no credential, no claim an authorization server issued, no scheme, no transport. Which credential admitted a caller is a question the transport answered and no use case has any business re-deciding, which is why nothing here can be asked it.
The user and the permissions are two axes rather than one, and neither implies the other. A permission says what the work may do and the user says whose mail it may do it to, so ownership adds no name to the published permission set and a grant however broad still reaches one user's mail. A principal acting for nobody is not a principal acting for everybody: the deployment administrator and this process's own identity carry no user, and every use case that reads or writes one user's mail refuses them. That holds for a record which belongs to a user without being mail as well — the contact book is the one — so a surface reaching such a record for somebody who is not the caller names the user it is for rather than resolving an absent one.
It is an ordinary class rather than a record, because two principals are never compared. A record's generated equality would compare Permissions by reference and report two identical grants as different, which is worse than having no equality at all.
The four factories below are the only way to obtain one, so a principal always states which kind it is and a kind added later cannot arrive with an unset identity. Process is a single instance because there is one process and it holds no per-work state.
Fields
- ProcessIdentityName
The name the process's own identity is reported under, which is MailFathom itself rather than anything an operator configured.
Properties
- Grant
Gets what this principal holds, each permission with the scopes it is held at, which is empty for every kind but a caller.
- Identity
Gets the identity the work was admitted under.
- Kind
Gets which of the three things this principal is.
- Permissions
Gets the permissions this principal holds at any scope, which is empty for every kind but a caller.
- Process
Gets the principal work no caller requested runs under.
Methods
- Caller(string, ScopedGrant)
Describes a caller the transport admitted that acts for no user's mail, holding each permission at the scopes it was granted at.
- Caller(string, IEnumerable<MailFathomPermission>)
Describes a caller the transport admitted that acts for no user's mail.
- CallerActingFor(UserId, string, ScopedGrant)
Describes a caller the transport admitted that acts for one user's mail, holding each permission at the scopes it was granted at.
- CallerActingFor(UserId, string, IEnumerable<MailFathomPermission>)
Describes a caller the transport admitted that acts for one user's mail.
- Holds(MailFathomPermission)
Reports whether this principal was granted one named capability, over the whole deployment where the capability reads a scope at all.
- HoldsOnlyBelowDeployment(MailFathomPermission)
Reports whether this principal holds one administrative capability only over part of the deployment — an organization or a user — and never over the whole of it.
- HoldsOver(MailFathomPermission, AdministrativeTarget)
Reports whether this principal was granted one named capability over one target.
- SignedCapability(UserId, string)
Describes the principal a verified signature produced.