Class PermissionContext
- Namespace
- Dynamicweb.Security.Permissions
- Assembly
- Dynamicweb.Security.dll
public class PermissionContext : IDisposable
- Inheritance
-
PermissionContext
- Implements
- Inherited Members
Constructors
PermissionContext(bool)
protected PermissionContext(bool pushOnStack = true)
Parameters
pushOnStack
bool
Properties
BasePermissionContext
Fallback permission context for when no permission context for logged on user exist.
public PermissionContext BasePermissionContext { get; set; }
Property Value
- PermissionContext
- permissionContext
Current
Gets the current permission context.
public static PermissionContext Current { get; }
Property Value
- PermissionContext
- permissionContext
CurrentId
Gets the id of the current permission context.
public string CurrentId { get; }
Property Value
- string
- Id
DefaultPermission
Default permission level to grant for all cases where no specific permission has been set for the current context (context is typically current user).
public virtual PermissionLevel DefaultPermission { get; }
Property Value
- PermissionLevel
- defaultPermission
Stack
protected static Stack<PermissionContext> Stack { get; }
Property Value
Methods
AddContext()
protected void AddContext()
Backend()
Creates a permission context for current backend user.
public static PermissionContext Backend()
Returns
- PermissionContext
- permissionContext
Remarks
If not backend user is logged in, then returns BasePermissionContext
DeleteAllPermissions(UnifiedPermissionQuery)
Deletes all permissions matching the query.
public void DeleteAllPermissions(UnifiedPermissionQuery query)
Parameters
query
UnifiedPermissionQuery- Target of permission
DeletePermission(string, UnifiedPermissionIdentifier)
Deletes all permissions for the specified userid and query.
public void DeletePermission(string userId, UnifiedPermissionIdentifier identifier)
Parameters
userId
string- Id of the user
identifier
UnifiedPermissionIdentifier- Target of permission
DeletePermission(string, string, string, string)
Deletes all permissions for the specified userid and query.
public void DeletePermission(string userId, string key, string name, string subName = "")
Parameters
Dispose()
Performs application-defined tasks associated with freeing, releasing or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
ElevatedPrivileges()
Creates a permission context that explicitly allows everything.
public static PermissionContext ElevatedPrivileges()
Returns
- PermissionContext
- permissionContext
ForceClearPermissions()
Force clears all permissions. Permissions in use may break and exceptions may occour. Use at own risk!
public void ForceClearPermissions()
Frontend()
Creates a permission context for current frontend user.
public static PermissionContext Frontend()
Returns
- PermissionContext
- permissionContext
Remarks
If not frontend user is logged in, then returns BasePermissionContext
GetAllPermissions(UnifiedPermissionQuery)
Gets all permissions matching the query.
public virtual IList<UnifiedPermission> GetAllPermissions(UnifiedPermissionQuery query)
Parameters
query
UnifiedPermissionQuery- Target of permission
Returns
GetPermission(UnifiedPermissionIdentifier)
Retrieves the permission level for the specified query.
public PermissionLevel GetPermission(UnifiedPermissionIdentifier identifier)
Parameters
identifier
UnifiedPermissionIdentifier- Target of permission
Returns
GetPermission(string, string)
Retrieves the permission level for the specified user and query.
public PermissionLevel GetPermission(string key, string name)
Parameters
Returns
GetPermission(string, string, string)
Retrieves the permission level for the specified user and query.
public PermissionLevel GetPermission(string key, string name, string subName)
Parameters
Returns
SetMapper<T>(Func<T>)
Allows exchanging the default mapper.
Used when ThreadStatic cannot be used to ensure the permission stack. Do not use this, if you're unsure what this means.
public static void SetMapper<T>(Func<T> contextMapper) where T : IPermissionContextStackMapper
Parameters
contextMapper
Func<T>- contextMapper
Type Parameters
T
SetPermission(int, PermissionLevel, IPermissionControlled)
Sets permissions for the specified userid and query.
public void SetPermission(int userId, PermissionLevel permission, IPermissionControlled permissionControlledObject)
Parameters
userId
int- If of the user
permission
PermissionLevel- Permission level
permissionControlledObject
IPermissionControlled- controlled object
SetPermission(int, PermissionLevel, string, string, string)
Sets permissions for the specified userid and query.
public void SetPermission(int userId, PermissionLevel permission, string key, string name, string subName = "")
Parameters
userId
int- If of the user
permission
PermissionLevel- Permission level
key
string- Key
name
string- Name
subName
string- Sub name
SetPermission(string, PermissionLevel, IPermissionControlled)
Sets permissions for the specified userid and query.
public void SetPermission(string userId, PermissionLevel permission, IPermissionControlled permissionControlledObject)
Parameters
userId
string- If of the user
permission
PermissionLevel- Permission level
permissionControlledObject
IPermissionControlled- controlled object
SetPermission(string, PermissionLevel, UnifiedPermissionIdentifier)
Sets permissions for the specified userid and query.
public void SetPermission(string userId, PermissionLevel permission, UnifiedPermissionIdentifier identifier)
Parameters
userId
string- Id of the user
permission
PermissionLevel- Permission level
identifier
UnifiedPermissionIdentifier- Target of permission
SetPermission(string, PermissionLevel, string, string, string)
Sets permissions for the specified userid and query.
public void SetPermission(string userId, PermissionLevel permission, string key, string name, string subName = "")
Parameters
userId
string- If of the user
permission
PermissionLevel- Permission level
key
string- Key
name
string- Name
subName
string- Sub name
TryGetPermission(UnifiedPermissionIdentifier, ref PermissionLevel?)
Retrieves the permission level for the specified query.
public virtual bool TryGetPermission(UnifiedPermissionIdentifier identifier, ref PermissionLevel? permissionLevel)
Parameters
identifier
UnifiedPermissionIdentifier- Target of permission
permissionLevel
PermissionLevel?- Permission level
Returns
UserContext(LimitedUser)
Creates a permission context based upon a users id.
public static PermissionContext UserContext(LimitedUser user)
Parameters
user
LimitedUser- User
Returns
- PermissionContext
- permissionContext
Remarks
If id is not valid then BasePermissionContext