Skip to content

DmPolicyExtensions ​

Namespace: MJCZone.DapperMatic.Security

Assembly: MJCZone.DapperMatic

Summary ​

Narrows a policy, fluently: <c>DmPolicy.Allow(DmAction.ReadWrite, "staff").InSchemas("sales").Where("tenant_id eq @tenant.id")</c>.

static public

Contents ​

Methods (20)

Methods ​

MethodSummary
NamedNames the policy, as effective permissions show it.
WithClaimRequires a claim of the caller: a value, or <c>*</c> for any.
WhenApplies the policy only to requests whose context satisfies a predicate: in code, with the caller, t...
OnDatasourcesCovers only these datasources, by id or pattern with <c>*</c>.
InSchemasCovers only these schemas, by name or pattern; <c>_</c> is the default schema of a reque...
ExceptSchemasLeaves out these schemas, by name or pattern.
OnTablesCovers only these tables and views, by name or pattern.
OnFunctionsCovers running only these functions, by name or pattern. A policy naming functions grants Execute ...
ExceptTablesLeaves out these tables and views, by name or pattern.
OnTablesWithColumnsCovers, for row actions, only tables having all these columns: one policy for every table with a &lt...
OnlyColumnsLets callers read and write only these columns.
ExceptColumnsKeeps these columns from callers.
WhereLimits the rows read, updated and deleted, with a condition in the query syntax over the table's own...
WithinOwnTenantMakes a grant of ManageAccess one for the caller's own tenant: its holders keep policies that belo...
CheckSets a condition every row inserted or updated must satisfy, in the query syntax.
PresetWrites a column on insert and update whatever the request says: a value of the request's context suc...
GetType
ToString
Equals
GetHashCode

Named ​

Names the policy, as effective permissions show it.

csharp
DmPolicy Named(DmPolicy policy, string name)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • name (string) - The name.

Returns ​

Type: DmPolicy

The same policy, for chaining.

WithClaim ​

Requires a claim of the caller: a value, or <c>*</c> for any.

csharp
DmPolicy WithClaim(DmPolicy policy, string type, string value)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • type (string) - The claim type.
  • value (string) - .

Returns ​

Type: DmPolicy

The same policy, for chaining.

When ​

Applies the policy only to requests whose context satisfies a predicate: in code, with the caller, the tenant, and the request's services for anything else.

csharp
DmPolicy When(DmPolicy policy, DmAccessContext predicate)

Parameters ​

Returns ​

Type: DmPolicy

The same policy, for chaining.

OnDatasources ​

Covers only these datasources, by id or pattern with <c>*</c>.

csharp
OnDatasources(DmPolicy policy, String[] datasources)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • datasources (String[]) - The datasources.

Returns ​

The same policy, for chaining.

InSchemas ​

Covers only these schemas, by name or pattern; <c>_</c> is the default schema of a request naming none.

csharp
InSchemas(DmPolicy policy, String[] schemas)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • schemas (String[]) - The schemas.

Returns ​

The same policy, for chaining.

ExceptSchemas ​

Leaves out these schemas, by name or pattern.

csharp
ExceptSchemas(DmPolicy policy, String[] schemas)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • schemas (String[]) - The schemas.

Returns ​

The same policy, for chaining.

OnTables ​

Covers only these tables and views, by name or pattern.

csharp
OnTables(DmPolicy policy, String[] tables)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • tables (String[]) - The tables.

Returns ​

The same policy, for chaining.

OnFunctions ​

Covers running only these functions, by name or pattern. A policy naming functions grants Execute and nothing else.

csharp
OnFunctions(DmPolicy policy, String[] functions)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • functions (String[]) - The functions.

Returns ​

The same policy, for chaining.

ExceptTables ​

Leaves out these tables and views, by name or pattern.

csharp
ExceptTables(DmPolicy policy, String[] tables)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • tables (String[]) - The tables.

Returns ​

The same policy, for chaining.

OnTablesWithColumns ​

Covers, for row actions, only tables having all these columns: one policy for every table with a <c>tenant_id</c>, in whatever schema.

csharp
OnTablesWithColumns(DmPolicy policy, String[] columns)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • columns (String[]) - The columns.

Returns ​

The same policy, for chaining.

OnlyColumns ​

Lets callers read and write only these columns.

csharp
OnlyColumns(DmPolicy policy, String[] columns)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • columns (String[]) - The columns.

Returns ​

The same policy, for chaining.

ExceptColumns ​

Keeps these columns from callers.

csharp
ExceptColumns(DmPolicy policy, String[] columns)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • columns (String[]) - The columns.

Returns ​

The same policy, for chaining.

Where ​

Limits the rows read, updated and deleted, with a condition in the query syntax over the table's own columns and values of the request: <c>tenant_id eq null or tenant_id in @tenant.below</c>.

csharp
DmPolicy Where(DmPolicy policy, string filter)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • filter (string) - The condition.

Returns ​

Type: DmPolicy

The same policy, for chaining.

WithinOwnTenant ​

Makes a grant of ManageAccess one for the caller's own tenant: its holders keep policies that belong to their tenant, held to its rows, giving no more than they may do themselves.

csharp
DmPolicy WithinOwnTenant(DmPolicy policy)

Parameters ​

  • policy (DmPolicy) - The policy to change.

Returns ​

Type: DmPolicy

The same policy, for chaining.

Check ​

Sets a condition every row inserted or updated must satisfy, in the query syntax.

csharp
DmPolicy Check(DmPolicy policy, string check)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • check (string) - The condition.

Returns ​

Type: DmPolicy

The same policy, for chaining.

Preset ​

Writes a column on insert and update whatever the request says: a value of the request's context such as <c>@tenant.id</c>, or a fixed text.

csharp
DmPolicy Preset(DmPolicy policy, string column, string value)

Parameters ​

  • policy (DmPolicy) - The policy to change.
  • column (string) - The column.
  • value (string) - The value.

Returns ​

Type: DmPolicy

The same policy, for chaining.

GetType ​

csharp
GetType()

ToString ​

csharp
ToString()

Equals ​

csharp
Equals()

GetHashCode ​

csharp
GetHashCode()