Skip to content

BasePermissionService class

namespace: Serenity.Extensions   assembly: Serenity.Extensions

Base permission service that provides common functionality for permission services.

public abstract class BasePermissionService : IPermissionService, ITransientGrantor
parameter description
userAccessor User accessor
rolePermissions Role permission service
httpContextItemsAccessor HTTP context items accessor
options The options, with the super admins. Without them, there is no super admin unless IsSuperAdmin is overridden.

Public Members

name description
virtual GetGranted()
virtual Grant(…)
virtual GrantAll()
HasPermission(…) Returns true if the current user has the permission. The permission may also be a logical expression with !, &, | and parentheses, e.g. "A|B", in which case each permission key in it is checked separately with HasPermissionKey. Override HasPermissionKey to change how a single permission key is checked, so that the checks apply to each key in an expression.
virtual IsAllGranted()
virtual UndoGrant()
static GetImplicitPermissions(…) Gets implicit permissions defined in the application.

Protected Members

name description
BasePermissionService(…) Base permission service that provides common functionality for permission services.
virtual AnonymousUsersHavePermission(…) Checks if anonymous users have the specified permission. By default, they don't have any permission.
abstract GetUserRoles(…) Gets the roles of the specified user.
virtual HasImpersonationPermission(…) Returns true if the provided user has the permission to impersonate as another user. Unless overridden, no user have this permission.
virtual HasPermissionKey(…) Returns true if the current user has a single permission key, e.g. not an expression.
virtual IsAsterisk(…) Gets whether the specified permission is an asterisk, e.g. "*" that grants permission to all including anonymous users.
virtual IsDeny(…) Gets whether the specified permission is "DENY", which denies access to all users including super administrators.
virtual IsImpersonationPermission(…) Gets whether the specified permission is an impersonation permission. By default, impersonation permissions are permissions that start with "ImpersonateAs".
virtual IsQuestionMark(…) Gets whether the specified permission is a question mark, e.g. "?" that grants permission to logged in users.
virtual IsSuperAdmin(…) Gets whether the specified user is a super admin: one of the SuperAdmins when the options are given, otherwise no one.
virtual IsTransientlyGranted(…) Checks if the transient grantor has the specified permission.
virtual IsValidKey(…) Gets whether the specified permission is a valid permission key. By default, a permission key is valid if it is not null or empty.
virtual SuperAdminHasPermission(…) Checks if the super admin has the specified permission. By default, super admin has all permissions.
abstract UserHasPermission(…) Gets if user has the specified permission directly, not via roles. Returns null if permission is not granted or denied directly.

See Also