Skip to content

AuthorizationExtensions class

namespace: Serenity   assembly: Serenity.Net.Core

Provides helper extension methods for authorization, permission checks, and user retrieval.

public static class AuthorizationExtensions

Public Members

name description
static GetAuditIdentifier(…) Gets the identifier of the user who is responsible for what the principal does, for the audit fields and logs, e.g. InsertUserId: the user who acts on behalf of the principal (Actor), e.g. an administrator who impersonates the user, else the user of the principal (GetIdentifier).
static GetIdentifier(…) Gets the value of the NameIdentifier claim from the specified principal.
static GetUserDefinition(…) Gets the user definition for the specified principal. (3 methods)
static GetUserDefinition<TUserDefinition>(…) Gets the typed user definition for the specified principal.
static Impersonate(…) Impersonates the user with the specified username.
static IsLoggedIn(…) Determines whether the user accessed via userAccessor is authenticated. (2 methods)
static RemoveCachedUser(…) Removes the specified user from the cache. (2 methods)
static ValidateLoggedIn(…) Ensures a user is currently authenticated, throwing a validation error with code NotLoggedIn otherwise.
static ValidatePermission(…) Ensures the current user has the specified permission, throwing a validation error with code AccessDenied otherwise.

See Also