DmPolicy
Namespace: MJCZone.DapperMatic.Security
Assembly: MJCZone.DapperMatic
Summary
Who may do what, to which tables, rows and columns. Nothing is allowed unless a permissive policy grants it.
sealed public
Contents
Constructors (1) | Methods (7) | Properties (21)
Constructors
DmPolicy
DmPolicy()Methods
| Method | Summary |
|---|---|
| Allow | Creates a policy granting actions to roles: <c>anonymous</c>, <c>authenticated<... |
| Restrict | Creates a policy fencing actions for roles, or for every caller when none is given: its filter, chec... |
| Copy | Copies the policy, with lists of its own. |
| ToString | |
| GetType | |
| Equals | |
| GetHashCode |
Allow
Creates a policy granting actions to roles: <c>anonymous</c>, <c>authenticated</c>, <c>*</c> for every caller, or role names. Narrow it with the methods of DmPolicyExtensions.
Allow(DmAction actions, String[] roles)Parameters
- actions (DmAction) - What it grants.
- roles (String[]) - Who it grants it to; none, to grant by claims or a predicate instead.
Returns
The policy.
Restrict
Creates a policy fencing actions for roles, or for every caller when none is given: its filter, check and columns hold whatever the grants allow.
Restrict(DmAction actions, String[] roles)Parameters
- actions (DmAction) - What it fences.
- roles (String[]) - Who it fences; none for every caller.
Returns
The policy.
Copy
Copies the policy, with lists of its own.
DmPolicy Copy()Returns
Type: DmPolicy
The copy.
ToString
string ToString()Returns
Type: string
GetType
GetType()Equals
Equals()GetHashCode
GetHashCode()Properties
Name
Gets or sets the policy's name, shown in effective permissions.
Type: string?
Kind
Gets or sets whether the policy grants or fences.
Type: DmPolicyKind
Actions
Gets or sets what the policy lets callers do (or, restrictive, what it fences).
Type: DmAction
Roles
Gets the roles the policy is for: <c>anonymous</c>, <c>authenticated</c>, <c>*</c>, or role names.
Type: List<string>
Claims
Gets claims the caller must have, by type: a value, or <c>*</c> for any.
Type: Dictionary<string, string>
Predicate
Gets or sets a predicate in code the request's context must satisfy.
Type: Func<DmAccessContext, bool>
Datasources
Gets the datasources the policy covers, by id or pattern; empty for all.
Type: List<string>
Schemas
Gets the schemas the policy covers, by name or pattern; <c>_</c> for the default one; empty for all.
Type: List<string>
ExceptSchemas
Gets the schemas the policy leaves out, by name or pattern.
Type: List<string>
Tables
Gets the tables and views the policy covers, by name or pattern; empty for all.
Type: List<string>
ExceptTables
Gets the tables and views the policy leaves out, by name or pattern.
Type: List<string>
Functions
Gets the functions the policy lets callers run (Execute), by name or pattern; empty for every one, when the policy is confined to no schema or table.
Type: List<string>
WithColumns
Gets columns a table must have for the policy's row actions to cover it.
Type: List<string>
Columns
Gets the columns the policy lets callers read and write; empty for all.
Type: List<string>
ExcludeColumns
Gets the columns the policy keeps from callers.
Type: List<string>
Filter
Gets or sets the rows the policy covers for reads, updates and deletes; null for all.
Type: string?
Check
Gets or sets the condition every row inserted or updated must satisfy. Null or blank, as in PostgreSQL, is the Filter: a row written must be one the policy covers, so a write cannot move a row out of a tenant's reach. A policy that lets callers write rows its filter does not cover says so with a check of its own, such as <c>true</c>.
Type: string?
Presets
Gets values the policy writes on insert and update, by column: a path such as <c>@tenant.id</c>, or a fixed text.
Type: Dictionary<string, string?>
Source
Gets or sets where the policy came from: code, configuration, or the policies kept by DapperMatic.
Type: string?
Tenant
Gets or sets the tenant a policy belongs to, as one a tenant's administrator keeps: it applies only to requests in that tenant, and only to that tenant's rows (or datasource or schema). Null for a policy of the whole application.
Type: string?
WithinOwnTenant
Gets or sets a value indicating whether a grant of ManageAccess is for the caller's own tenant only: its holders keep policies that belong to their tenant, giving no more than they may do themselves, and nothing else.
Type: bool