DapperMaticAccessManager
Namespace: MJCZone.DapperMatic.AspNetCore.Services
Assembly: MJCZone.DapperMatic.AspNetCore
Summary
The built-in accounts, for administrators: those who manage access to everything see and manage every account, its platform roles and grants; a tenant's administrators manage their tenant's members and invitations (giving only roles they may give) and see, and revoke, the grants to their tenant. Callers signed in by a key manage none of it.
sealed public
Contents
Constructors (1) | Methods (40)
Constructors
DapperMaticAccessManager
Initializes a new instance of the DapperMaticAccessManager class.
DapperMaticAccessManager(
DapperMaticPolicySet policies,
DapperMaticStoredAccess stored,
IDapperMaticPermissions permissions,
IDapperMaticAuditLogger auditLogger,
IDapperMaticService service,
DapperMaticOptions} options,
DapperMaticChangeLog changes,
IDapperMaticDatasourceRepository datasources,
IDbConnectionFactory connections,
IServiceProvider services)Parameters
- policies (DapperMaticPolicySet) - The policies in force.
- stored (DapperMaticStoredAccess) - The policies and tenants kept by DapperMatic.
- permissions (IDapperMaticPermissions) - The permissions every operation is authorized by.
- auditLogger (IDapperMaticAuditLogger) - The audit logger.
- service (IDapperMaticService) - The service, for a table's columns.
- options (DapperMaticOptions}) - The options, with the tenants of configuration.
- changes (DapperMaticChangeLog) - Where webhooks' changes are noted, for their status; or null.
- datasources (IDapperMaticDatasourceRepository) - The datasources, for webhooks' status; or null.
- connections (IDbConnectionFactory) - Makes connections to them; or null.
- services (IServiceProvider) - The request's services, for the API keys once they are turned on; or null.
Methods
| Method | Summary |
|---|---|
| GetAccountsAsync | Lists accounts: every one, a tenant's members, or a tenant administrator's members. |
| SetPlatformRolesAsync | Sets an account's platform roles: by those who manage access to everything. |
| SetDisabledAsync | Turns an account off (its sign-ins, sessions and keys end) or on: by those who manage access to ever... |
| SaveMembershipAsync | Gives an account a membership of a tenant, or changes its roles there. |
| DeleteMembershipAsync | Removes an account's membership of a tenant. |
| GetGrantsAsync | Lists grants: to a tenant administrator's tenant, or to any tenant for those who manage everything. |
| GrantAsync | Grants a platform user a tenant's roles until a time (within the longest grant): by those who manage... |
| RevokeGrantAsync | Revokes a grant: the tenant's administrators may revoke those to their tenant. |
| GetInvitationsAsync | Lists invitations not accepted: a tenant administrator's tenant's, or any for those who manage every... |
| InviteAsync | Invites an email: a tenant administrator to their tenant (roles they may give); those who manage eve... |
| DeleteInvitationAsync | Withdraws an invitation. |
| GetPoliciesAsync | Lists the policies in force that the caller may manage: of code and configuration (their <c>So... |
| GetPolicyAsync | Gets a policy in force by its name: the application's, or, with <paramref name="tenant" />, a ... |
| SavePolicyAsync | Adds a policy to those kept by DapperMatic, or replaces the kept one of the same name (and tenant). ... |
| DeletePolicyAsync | Removes a policy kept by DapperMatic: the application's, or, with <paramref name="tenant" />, ... |
| GetTenantsAsync | Lists the tenants the caller may manage: of configuration, and kept by DapperMatic (which win). |
| GetTenantAsync | Gets a tenant by its id. |
| SaveTenantAsync | Adds a tenant to those kept by DapperMatic, or replaces the kept one of the same id. A tenant of con... |
| DeleteTenantAsync | Removes a tenant kept by DapperMatic. |
| ExportAsync | Exports the policies and tenants kept by DapperMatic that the caller may manage. |
| ImportAsync | Imports policies and tenants: every one is checked before any is kept. Importing needs access manage... |
| GetEffectiveAsync | Works out what the policies let the caller do to a datasource, schema, table or view: for a user int... |
| GetServiceAccountsAsync | Lists the service accounts the caller manages: a tenant administrator's, their tenant's. |
| SaveServiceAccountAsync | Adds a service account, or replaces the kept one of the same name (and tenant). A tenant's administr... |
| DeleteServiceAccountAsync | Removes a kept service account, and revokes its keys. |
| CreateServiceKeyAsync | Makes a key for a service account: shown this once. |
| GetKeysAsync | Lists keys the caller manages, without their secrets: every one, or a tenant administrator's tenant'... |
| RevokeKeyAsync | Revokes a key the caller manages: it no longer signs in, and is still listed. |
| GetOwnKeysAsync | Lists the caller's own personal keys. |
| CreateOwnKeyAsync | Makes a personal key for the caller, in their tenant: it acts as them, as they are each time it is u... |
| RevokeOwnKeysAsync | Revokes one of the caller's personal keys, or every one. |
| GetWebhooksAsync | Lists the webhooks the caller may manage, their secrets masked: of code and configuration, and kept.... |
| GetWebhookAsync | Gets a webhook by its name, its secret masked. |
| SaveWebhookAsync | Adds a webhook to those kept, or replaces the kept one of the same name (and tenant); a secret left ... |
| DeleteWebhookAsync | Removes a webhook kept by DapperMatic. |
| GetWebhookStatusAsync | Reads where a webhook's messages have got to, in each datasource it hears: the messages taken and dr... |
| GetType | |
| ToString | |
| Equals | |
| GetHashCode |
GetAccountsAsync
Lists accounts: every one, a tenant's members, or a tenant administrator's members.
Task<IReadOnlyList<DapperMaticAccountSummary>> GetAccountsAsync(
DapperMaticOperation context,
string tenant,
string after,
int take,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- tenant (string) - A tenant whose members to list, or null.
- after (string) - The last email of the page before, or null.
- take (int) - How many at most (1 to 1,000).
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyList<DapperMaticAccountSummary>>
The accounts.
SetPlatformRolesAsync
Sets an account's platform roles: by those who manage access to everything.
Task SetPlatformRolesAsync(
DapperMaticOperation context,
string userId,
String} roles,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- userId (string) - The account's id.
- roles (String}) - The roles.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
SetDisabledAsync
Turns an account off (its sign-ins, sessions and keys end) or on: by those who manage access to everything.
Task SetDisabledAsync(
DapperMaticOperation context,
string userId,
bool disabled,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- userId (string) - The account's id.
- disabled (bool) - Whether it is off.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
SaveMembershipAsync
Gives an account a membership of a tenant, or changes its roles there.
Task<DapperMaticMembershipInfo> SaveMembershipAsync(
DapperMaticOperation context,
string tenant,
string userId,
DapperMaticMembershipRequest request,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- tenant (string) - The tenant (a tenant administrator's own).
- userId (string) - The account's id.
- request (DapperMaticMembershipRequest) - The roles.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticMembershipInfo>
The membership.
DeleteMembershipAsync
Removes an account's membership of a tenant.
Task DeleteMembershipAsync(
DapperMaticOperation context,
string tenant,
string userId,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- tenant (string) - The tenant (a tenant administrator's own).
- userId (string) - The account's id.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
GetGrantsAsync
Lists grants: to a tenant administrator's tenant, or to any tenant for those who manage everything.
Task<IReadOnlyList<DapperMaticMembershipInfo>> GetGrantsAsync(
DapperMaticOperation context,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- tenant (string) - A tenant, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyList<DapperMaticMembershipInfo>>
The grants, live or not.
GrantAsync
Grants a platform user a tenant's roles until a time (within the longest grant): by those who manage everything. The audit names the grant on everything done under it.
Task<DapperMaticMembershipInfo> GrantAsync(
DapperMaticOperation context,
DapperMaticGrantRequest request,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- request (DapperMaticGrantRequest) - The account, tenant, roles, end and reason.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticMembershipInfo>
The grant.
RevokeGrantAsync
Revokes a grant: the tenant's administrators may revoke those to their tenant.
Task RevokeGrantAsync(
DapperMaticOperation context,
string id,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- id (string) - The grant's id.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
GetInvitationsAsync
Lists invitations not accepted: a tenant administrator's tenant's, or any for those who manage everything.
Task<IReadOnlyList<DapperMaticInvitationInfo>> GetInvitationsAsync(
DapperMaticOperation context,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- tenant (string) - A tenant, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyList<DapperMaticInvitationInfo>>
The invitations.
InviteAsync
Invites an email: a tenant administrator to their tenant (roles they may give); those who manage everything to any tenant, or to the platform.
Task<DapperMaticInvitationCreated> InviteAsync(
DapperMaticOperation context,
DapperMaticInvitationRequest request,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- request (DapperMaticInvitationRequest) - The email, tenant and roles.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticInvitationCreated>
The invitation, its token shown this once.
DeleteInvitationAsync
Withdraws an invitation.
Task DeleteInvitationAsync(
DapperMaticOperation context,
string id,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- id (string) - The invitation's id.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
GetPoliciesAsync
Lists the policies in force that the caller may manage: of code and configuration (their <c>Source</c> says so), and kept by DapperMatic. A tenant's administrator sees their tenant's; another administrator sees every one they manage, or one tenant's when <paramref name="tenant" /> names it.
Task<IReadOnlyList<DmPolicy>> GetPoliciesAsync(
DapperMaticOperation context,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- tenant (string) - A tenant whose policies to list, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyList<DmPolicy>>
The policies.
GetPolicyAsync
Gets a policy in force by its name: the application's, or, with <paramref name="tenant" />, a tenant's (a tenant's administrator always gets their tenant's).
Task<DmPolicy> GetPolicyAsync(
DapperMaticOperation context,
string name,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The policy's name.
- tenant (string) - The tenant the policy is one of, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DmPolicy>
The policy.
SavePolicyAsync
Adds a policy to those kept by DapperMatic, or replaces the kept one of the same name (and tenant). It applies to the next request. A tenant's administrator keeps their tenant's policies only: each is held to the tenant's rows (or datasource or schema), names its tables, and gives no more than the administrator may do.
Task<DmPolicy> SavePolicyAsync(
DapperMaticOperation context,
string name,
DmPolicy policy,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The policy's name.
- policy (DmPolicy) - The policy.
- tenant (string) - The tenant the policy is one of, or null for the application's.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DmPolicy>
The policy kept.
DeletePolicyAsync
Removes a policy kept by DapperMatic: the application's, or, with <paramref name="tenant" />, a tenant's (a tenant's administrator always removes their tenant's).
Task DeletePolicyAsync(
DapperMaticOperation context,
string name,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The policy's name.
- tenant (string) - The tenant the policy is one of, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
GetTenantsAsync
Lists the tenants the caller may manage: of configuration, and kept by DapperMatic (which win).
Task<IReadOnlyDictionary<string, DapperMaticTenantSettings>> GetTenantsAsync(
DapperMaticOperation context,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyDictionary<string, DapperMaticTenantSettings>>
The tenants, by id.
GetTenantAsync
Gets a tenant by its id.
Task<DapperMaticTenantSettings> GetTenantAsync(
DapperMaticOperation context,
string id,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- id (string) - The tenant's id.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticTenantSettings>
What is known of it.
SaveTenantAsync
Adds a tenant to those kept by DapperMatic, or replaces the kept one of the same id. A tenant of configuration with the id is overridden.
Task<DapperMaticTenantSettings> SaveTenantAsync(
DapperMaticOperation context,
string id,
DapperMaticTenantSettings tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- id (string) - The tenant's id.
- tenant (DapperMaticTenantSettings) - What is known of it.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticTenantSettings>
The tenant kept.
DeleteTenantAsync
Removes a tenant kept by DapperMatic.
Task DeleteTenantAsync(
DapperMaticOperation context,
string id,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- id (string) - The tenant's id.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
ExportAsync
Exports the policies and tenants kept by DapperMatic that the caller may manage.
Task<DapperMaticAccessDocument> ExportAsync(
DapperMaticOperation context,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticAccessDocument>
The policies and tenants.
ImportAsync
Imports policies and tenants: every one is checked before any is kept. Importing needs access management for every datasource and schema.
Task ImportAsync(
DapperMaticOperation context,
DapperMaticAccessDocument document,
bool replace,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- document (DapperMaticAccessDocument) - The policies and tenants.
- replace (bool) - Whether they replace everything kept; otherwise they are added, replacing those of the same names.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
GetEffectiveAsync
Works out what the policies let the caller do to a datasource, schema, table or view: for a user interface to show what is possible, or an administrator to see why something is refused. The conditions and the policies' names are shown only to a caller who manages access to the resource.
Task<DapperMaticEffectiveAccess> GetEffectiveAsync(
DapperMaticOperation context,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation, naming the resource.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticEffectiveAccess>
The rules for each action.
GetServiceAccountsAsync
Lists the service accounts the caller manages: a tenant administrator's, their tenant's.
Task<IReadOnlyList<DapperMaticServiceAccount>> GetServiceAccountsAsync(
DapperMaticOperation context,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- tenant (string) - A tenant whose accounts to list, or null for every one.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyList<DapperMaticServiceAccount>>
The accounts: of code and configuration, and kept.
SaveServiceAccountAsync
Adds a service account, or replaces the kept one of the same name (and tenant). A tenant's administrator keeps their tenant's, giving only roles they hold or roles only their tenant's policies name, and no claims.
Task<DapperMaticServiceAccount> SaveServiceAccountAsync(
DapperMaticOperation context,
string name,
DapperMaticServiceAccount account,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The account's name.
- account (DapperMaticServiceAccount) - The account.
- tenant (string) - The tenant it is one of, or null for the application's.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticServiceAccount>
The account kept.
DeleteServiceAccountAsync
Removes a kept service account, and revokes its keys.
Task DeleteServiceAccountAsync(
DapperMaticOperation context,
string name,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The account's name.
- tenant (string) - The tenant it is one of, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
CreateServiceKeyAsync
Makes a key for a service account: shown this once.
Task<ApiKeyCreated> CreateServiceKeyAsync(
DapperMaticOperation context,
string name,
ApiKeyRequest request,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The account's name.
- request (ApiKeyRequest) - The key's name, expiry and limits.
- tenant (string) - The tenant the account is one of, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<ApiKeyCreated>
The key, and what is kept of it.
GetKeysAsync
Lists keys the caller manages, without their secrets: every one, or a tenant administrator's tenant's.
Task<IReadOnlyList<ApiKeyInfo>> GetKeysAsync(
DapperMaticOperation context,
DapperMaticKeyFilter filter,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- filter (DapperMaticKeyFilter) - Which keys.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyList<ApiKeyInfo>>
The keys.
RevokeKeyAsync
Revokes a key the caller manages: it no longer signs in, and is still listed.
Task RevokeKeyAsync(
DapperMaticOperation context,
string id,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- id (string) - The key's id.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
GetOwnKeysAsync
Lists the caller's own personal keys.
Task<IReadOnlyList<ApiKeyInfo>> GetOwnKeysAsync(
DapperMaticOperation context,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyList<ApiKeyInfo>>
The keys.
CreateOwnKeyAsync
Makes a personal key for the caller, in their tenant: it acts as them, as they are each time it is used, never more. Shown this once.
Task<ApiKeyCreated> CreateOwnKeyAsync(
DapperMaticOperation context,
ApiKeyRequest request,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- request (ApiKeyRequest) - The key's name, expiry and limits.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<ApiKeyCreated>
The key, and what is kept of it.
RevokeOwnKeysAsync
Revokes one of the caller's personal keys, or every one.
Task<int> RevokeOwnKeysAsync(
DapperMaticOperation context,
string id,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- id (string) - The key's id, or null for every one.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<int>
How many were revoked.
GetWebhooksAsync
Lists the webhooks the caller may manage, their secrets masked: of code and configuration, and kept. A tenant's administrator sees their tenant's.
Task<IReadOnlyList<DapperMaticWebhook>> GetWebhooksAsync(
DapperMaticOperation context,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- tenant (string) - A tenant whose webhooks to list, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyList<DapperMaticWebhook>>
The webhooks.
GetWebhookAsync
Gets a webhook by its name, its secret masked.
Task<DapperMaticWebhook> GetWebhookAsync(
DapperMaticOperation context,
string name,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The webhook's name.
- tenant (string) - The tenant it is one of, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticWebhook>
The webhook.
SaveWebhookAsync
Adds a webhook to those kept, or replaces the kept one of the same name (and tenant); a secret left out, or masked, keeps the one kept. A tenant's administrator keeps their tenant's: it names its datasource and the tables, each one the administrator may read, and hears only the tenant's changes. Its address may not be an internal one unless the options allow it.
Task<DapperMaticWebhook> SaveWebhookAsync(
DapperMaticOperation context,
string name,
DapperMaticWebhook webhook,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The webhook's name.
- webhook (DapperMaticWebhook) - The webhook.
- tenant (string) - The tenant it is one of, or null for the application's.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<DapperMaticWebhook>
The webhook kept, its secret masked.
DeleteWebhookAsync
Removes a webhook kept by DapperMatic.
Task DeleteWebhookAsync(
DapperMaticOperation context,
string name,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The webhook's name.
- tenant (string) - The tenant it is one of, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task
A task.
GetWebhookStatusAsync
Reads where a webhook's messages have got to, in each datasource it hears: the messages taken and dropped, the attempts at the one waiting, and its last error.
Task<IReadOnlyDictionary<string, DapperMaticWebhookStatus>> GetWebhookStatusAsync(
DapperMaticOperation context,
string name,
string tenant,
CancellationToken cancellationToken)Parameters
- context (DapperMaticOperation) - The operation.
- name (string) - The webhook's name.
- tenant (string) - The tenant it is one of, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<IReadOnlyDictionary<string, DapperMaticWebhookStatus>>
Its state in each datasource, by datasource.
GetType
GetType()ToString
ToString()Equals
Equals()GetHashCode
GetHashCode()