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
namestringThe unique name of the policy. Must not be null or empty.
operationsint[]One or more operation identifiers that must all be granted.
Returns
- PoliciesBuilder
The same PoliciesBuilder instance for further chaining.
Exceptions
- ArgumentException
nameis 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
namestringThe unique name of the policy. Must not be null or empty.
scopestringThe scope every operation must be granted in. Must not be null or empty.
operationsint[]One or more operation identifiers that must all be granted within
scope.
Returns
- PoliciesBuilder
The same PoliciesBuilder instance for further chaining.
Exceptions
- ArgumentException
nameorscopeis 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
namestringThe 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
nameis 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
namestringThe unique name of the policy. Must not be null or empty.
operationsint[]One or more operation identifiers; being granted any of them satisfies the policy.
Returns
- PoliciesBuilder
The same PoliciesBuilder instance for further chaining.
Exceptions
- ArgumentException
nameis 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
namestringThe unique name of the policy. Must not be null or empty.
scopestringThe scope in which to check the operations. Must not be null or empty.
operationsint[]One or more operation identifiers; being granted any of them within
scopesatisfies the policy.
Returns
- PoliciesBuilder
The same PoliciesBuilder instance for further chaining.
Exceptions
- ArgumentException
nameorscopeis 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
namestringThe 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
nameis 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
namestringThe unique name of the policy. Must not be null or empty.
configureAction<AuthorizationPolicyBuilder>A delegate that configures the AuthorizationPolicyBuilder for the new policy.
Returns
- PoliciesBuilder
The same PoliciesBuilder instance for further chaining.
Exceptions
- ArgumentException
nameis null or empty.- ArgumentNullException
configureis null.
ConfigureAuthorization(Action<AuthorizationOptions>)
Applies additional configuration to the global AuthorizationOptions, such as setting DefaultPolicy or InvokeHandlersAfterFailure.
public PoliciesBuilder ConfigureAuthorization(Action<AuthorizationOptions> configure)
Parameters
configureAction<AuthorizationOptions>A delegate that configures the AuthorizationOptions.
Returns
- PoliciesBuilder
The same PoliciesBuilder instance for further chaining.
Exceptions
- ArgumentNullException
configureis null.