Class AppAuthorization
The default IAuthorization implementation, built from an Authorization data object. Roles and operations are grouped by scope; the methods without a scope parameter use the empty scope (Empty).
public class AppAuthorization : IAuthorization
- Inheritance
-
AppAuthorization
- Implements
- Inherited Members
Constructors
AppAuthorization(Authorization)
Initializes a new instance of the AppAuthorization class and indexes the roles and operations of the authorization data for fast look-up.
public AppAuthorization(Authorization authorizationData)
Parameters
authorizationDataAuthorizationThe authorization data (scopes, roles and operations) of the user.
Exceptions
- ConfigurationException
An entry of Operations or Roles has no
scope; the default scope is the empty string.
Properties
AuthorizationType
Gets the type of the authorization.
public string AuthorizationType { get; }
Property Value
- string
The type of the authorization.
Methods
IsAuthorized(params int[])
Determines whether the specified operations are authorized.
public bool IsAuthorized(params int[] operations)
Parameters
operationsint[]The operations.
Returns
- bool
trueif the specified operations is authorized; otherwise,false.
IsAuthorized(string)
Determines whether the specified operation is authorized in the default (empty) scope.
public bool IsAuthorized(string operation)
Parameters
operationstringThe operation name.
Returns
- bool
trueif the specified operation is authorized; otherwise,false.
Remarks
This overload exists so that IsAuthorized("Name") compiles: without it, a single string argument
matches both IsAuthorized(string, params int[]) and IsAuthorized(string, params string[])
with an empty operations array, which is ambiguous.
IsAuthorized(string, params int[])
Determines whether the specified operations are authorized in the specified scope.
public bool IsAuthorized(string scope, params int[] operations)
Parameters
Returns
- bool
trueif the specified scope is authorized; otherwise,false.
IsAuthorized(string, params string[])
Determines whether the specified operations are authorized in the specified scope.
public bool IsAuthorized(string scope, params string[] operations)
Parameters
Returns
- bool
trueif the specified scope is authorized; otherwise,false.
IsAuthorized(params string[])
Determines whether the specified operations are authorized.
public bool IsAuthorized(params string[] operations)
Parameters
operationsstring[]The operations.
Returns
- bool
trueif the specified operations is authorized; otherwise,false.
IsAuthorized<TAccess>(string, params TAccess[])
Determines whether all the specified operations, expressed with an enumeration, are authorized in the specified scope. The numeric value of each enumeration member is the operation identifier.
public bool IsAuthorized<TAccess>(string scope, params TAccess[] operations) where TAccess : struct, Enum
Parameters
scopestringThe scope.
operationsTAccess[]The operations.
Returns
Type Parameters
TAccessThe enumeration type whose members identify the operations.
IsAuthorized<TAccess>(params TAccess[])
Determines whether all the specified operations, expressed with an enumeration, are authorized in the empty scope. The numeric value of each enumeration member is the operation identifier.
public bool IsAuthorized<TAccess>(params TAccess[] operations) where TAccess : struct, Enum
Parameters
operationsTAccess[]The operations.
Returns
Type Parameters
TAccessThe enumeration type whose members identify the operations.
IsInRole(string)
Determines whether the user is defined in the specified role.
public bool IsInRole(string role)
Parameters
rolestringThe role.
Returns
- bool
trueif [is in role] [the specified role]; otherwise,false.
IsInRole(string, string)
/// Determines whether the user is defined in the specified role for the specific scope.
public bool IsInRole(string scope, string role)
Parameters
Returns
- bool
trueif [is in role] [the specified scope]; otherwise,false.
Operations()
Operations defined.
public string[] Operations()
Returns
- string[]
Operations(string)
Operations defined in the specified scope.
public string[] Operations(string scope)
Parameters
scopestringThe scope.
Returns
- string[]
Roles()
Roleses defined.
public string[] Roles()
Returns
- string[]
Roles(string)
Roleses defined in the specified scope.
public string[] Roles(string scope)
Parameters
scopestringThe scope.
Returns
- string[]
Scopes()
Scopeses for roles and operations.
public string[] Scopes()
Returns
- string[]