Table of Contents

Class PoliciesBuilder

Namespace
Arc4u.Authorization
Assembly
Arc4u.Authorization.dll

A fluent builder, returned by AddScopedOperationsPolicy(IServiceCollection, IEnumerable<string>, IEnumerable<Operation>), for registering additional authorization policies and tweaking AuthorizationOptions in a single chained expression.

public sealed class PoliciesBuilder
Inheritance
PoliciesBuilder
Inherited Members

Methods

AddAllOperations(string, params int[])

Registers a policy that is satisfied only when the current principal is granted all of the supplied operations in the default (empty) scope.

public PoliciesBuilder AddAllOperations(string name, params int[] operations)

Parameters

name string

The unique name of the policy. Must not be null or empty.

operations int[]

One or more operation identifiers that must all be granted.

Returns

PoliciesBuilder

The same PoliciesBuilder instance for further chaining.

Exceptions

ArgumentException

name is null or empty.

AddAllOperations(string, string, params int[])

Registers a policy that is satisfied only when the current principal is granted all of the supplied operations within the given scope.

public PoliciesBuilder AddAllOperations(string name, string scope, params int[] operations)

Parameters

name string

The unique name of the policy. Must not be null or empty.

scope string

The scope every operation must be granted in. Must not be null or empty.

operations int[]

One or more operation identifiers that must all be granted within scope.

Returns

PoliciesBuilder

The same PoliciesBuilder instance for further chaining.

Exceptions

ArgumentException

name or scope is null or empty.

AddAllOperations(string, params (string scope, int operation)[])

Registers a policy that is satisfied only when the current principal is granted all of the supplied (scope, operation) pairs, each within its own scope.

public PoliciesBuilder AddAllOperations(string name, params (string scope, int operation)[] scopedOperations)

Parameters

name string

The unique name of the policy. Must not be null or empty.

scopedOperations (string, int)[]

One or more (scope, operation) tuples. Use Empty for the default scope.

Returns

PoliciesBuilder

The same PoliciesBuilder instance for further chaining.

Exceptions

ArgumentException

name is null or empty.

AddAnyOperations(string, params int[])

Registers a policy that is satisfied as soon as the current principal is granted any one of the supplied operations in the default (empty) scope.

public PoliciesBuilder AddAnyOperations(string name, params int[] operations)

Parameters

name string

The unique name of the policy. Must not be null or empty.

operations int[]

One or more operation identifiers; being granted any of them satisfies the policy.

Returns

PoliciesBuilder

The same PoliciesBuilder instance for further chaining.

Exceptions

ArgumentException

name is null or empty.

AddAnyOperations(string, string, params int[])

Registers a policy that is satisfied as soon as the current principal is granted any one of the supplied operations within the given scope.

public PoliciesBuilder AddAnyOperations(string name, string scope, params int[] operations)

Parameters

name string

The unique name of the policy. Must not be null or empty.

scope string

The scope in which to check the operations. Must not be null or empty.

operations int[]

One or more operation identifiers; being granted any of them within scope satisfies the policy.

Returns

PoliciesBuilder

The same PoliciesBuilder instance for further chaining.

Exceptions

ArgumentException

name or scope is null or empty.

AddAnyOperations(string, params (string scope, int operation)[])

Registers a policy that is satisfied as soon as the current principal is granted any one of the supplied (scope, operation) pairs.

public PoliciesBuilder AddAnyOperations(string name, params (string scope, int operation)[] scopedOperations)

Parameters

name string

The unique name of the policy. Must not be null or empty.

scopedOperations (string, int)[]

One or more (scope, operation) tuples; being granted any pair satisfies the policy. Use Empty for the default scope.

Returns

PoliciesBuilder

The same PoliciesBuilder instance for further chaining.

Exceptions

ArgumentException

name is null or empty.

AddPolicy(string, Action<AuthorizationPolicyBuilder>)

Registers a named authorization policy built with the supplied delegate.

public PoliciesBuilder AddPolicy(string name, Action<AuthorizationPolicyBuilder> configure)

Parameters

name string

The unique name of the policy. Must not be null or empty.

configure Action<AuthorizationPolicyBuilder>

A delegate that configures the AuthorizationPolicyBuilder for the new policy.

Returns

PoliciesBuilder

The same PoliciesBuilder instance for further chaining.

Exceptions

ArgumentException

name is null or empty.

ArgumentNullException

configure is null.

ConfigureAuthorization(Action<AuthorizationOptions>)

Applies additional configuration to the global AuthorizationOptions, such as setting DefaultPolicy or InvokeHandlersAfterFailure.

public PoliciesBuilder ConfigureAuthorization(Action<AuthorizationOptions> configure)

Parameters

configure Action<AuthorizationOptions>

A delegate that configures the AuthorizationOptions.

Returns

PoliciesBuilder

The same PoliciesBuilder instance for further chaining.

Exceptions

ArgumentNullException

configure is null.