Class ScopedOperationsExtension
- Namespace
- Arc4u.Authorization
- Assembly
- Arc4u.Authorization.dll
Registers the authorization policies derived from the operations of an application.
public static class ScopedOperationsExtension
- Inheritance
-
ScopedOperationsExtension
- Inherited Members
Methods
AddScopedOperationsPolicy(IServiceCollection, IEnumerable<string>, IEnumerable<Operation>)
Registers one authorization policy per operation, named as the operation, and one per scope and operation, named {scope}:{operation name}.
A policy is satisfied when the current principal is granted the operation, in the default scope or in the given scope. The AllScopedOperationsHandler is registered to evaluate them.
public static PoliciesBuilder AddScopedOperationsPolicy(this IServiceCollection services, IEnumerable<string> scopes, IEnumerable<Operation> operations)
Parameters
servicesIServiceCollectionThe service collection.
scopesIEnumerable<string>The scopes for which the scoped policies are created.
operationsIEnumerable<Operation>The operations for which the policies are created.
Returns
- PoliciesBuilder
A PoliciesBuilder to register additional policies.
Examples
var operations = new[]
{
new Operation { Name = "ReadOrders", ID = 1 },
new Operation { Name = "WriteOrders", ID = 2 }
};
builder.Services.AddScopedOperationsPolicy(["Sales"], operations)
.AddAnyOperations("OrdersAccess", 1, 2);