C# Класс Rock.Security.Authorization

Static class for managing authorizations
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AllowAllUsers ( ISecured entity, string action, RockContext rockContext = null ) : void

Allows all users.

AllowPerson ( ISecured entity, string action, Person person, RockContext rockContext = null ) : void

Updates authorization rules for the entity so that the current person is allowed to perform the specified action.

AllowSecurityRole ( ISecured entity, string action, Group group, RockContext rockContext = null ) : void

Allows the security role.

AuthRules ( int entityTypeId, int entityId, string action ) : List

Returns the authorization rules for the specified entity and action.

Authorized ( ISecured entity, string action, Rock person ) : bool

Evaluates whether a selected person is allowed to perform the selected action on the selected entity.

Authorized ( ISecured entity, string action, SpecialRole specialRole ) : bool

Evaluates whether a selected user is allowed to perform the selected action on the selected entity.

CopyAuthorization ( ISecured sourceEntity, ISecured targetEntity ) : void

Copies the authorization.

CopyAuthorization ( ISecured sourceEntity, ISecured targetEntity, RockContext rockContext, string action = "" ) : void

Copies the authorizations from one ISecured object to another

This method will save any previous changes made to the context

DecodeEntityTypeName ( string encodedTypeName ) : string

Decodes the entity type name.

EncodeEntityTypeName ( Type iSecuredType ) : string

Encodes the entity type name for use in a URL

EncodeEntityTypeName ( string assemblyQualifiedName ) : string

Encodes the entity type name for use in a URL

FindAuthRules ( ISecured securableObject ) : IQueryable

Finds the auth rules.

Flush ( ) : void

Clear the static Authorizations object

IsPrivate ( ISecured entity, string action, Person person ) : bool

Determines whether the specified entity is private. Entity is considered private if only the current user has access. In this scenario, the first rule would give current user access, and second rule would deny all users.

Load ( ) : bool

Load the static Authorizations object

MakePrivate ( ISecured entity, string action, Person person, RockContext rockContext = null ) : void

Makes the entity private by setting up two authorization rules, one granting the selected person, and then another that denies all other users.

MakeUnPrivate ( ISecured entity, string action, Person person, RockContext rockContext = null ) : void

Removes that two authorization rules that made the entity private.

RefreshAction ( int entityTypeId, int entityId, string action, RockContext rockContext ) : void

Reloads the action.

ReloadAction ( int entityTypeId, int entityId, string action ) : void

Reloads the action.

ReloadAction ( int entityTypeId, int entityId, string action, RockContext rockContext ) : void

Reloads the action.

ReloadEntity ( int entityTypeId, int entityId, RockContext rockContext = null ) : void

Reloads the entity.

SetAuthCookie ( string userName, bool isPersisted, bool IsImpersonated ) : void

Sets the auth cookie.

Приватные методы

Метод Описание
FlushAuth ( ) : void

Clear the static Authorizations object

ItemAuthorized ( ISecured entity, string action, Rock person, bool isRootEntity, bool checkParentAuthority ) : bool?

Checks to see if a person is authorized

ItemAuthorized ( ISecured entity, string action, SpecialRole specialRole, bool isRootEntity, bool checkParentAuthority ) : bool?

Checks to see if a special role is authorized

LoadAuths ( int entityTypeId, int entityId, RockContext rockContext ) : List

Loads the authorizations

MyAllow ( ISecured entity, string action, Person person = null, Group group = null, SpecialRole specialRole = SpecialRole.None, RockContext rockContext = null ) : void

Creates authorization rules to make the entity private to selected person

MyAllowAllUsers ( ISecured entity, string action, RockContext rockContext ) : void

Mies the allow all users.

MyMakePrivate ( ISecured entity, string action, Person person, RockContext rockContext ) : void

Makes the entity private for the selected action and person

MyMakeUnPrivate ( ISecured entity, string action, Person person, RockContext rockContext ) : void

If the entity is currently private for selected person, removes all the rules

RefreshAction ( int entityTypeId, int entityId, string action ) : void

Reloads the authorizations for the specified entity and action.

RefreshEntity ( int entityTypeId, int entityId, RockContext rockContext = null ) : void

Reloads the entity.

ResetAction ( int entityTypeId, int entityId, string action, List authRules ) : void

Resets the action.

Описание методов

AllowAllUsers() публичный статический Метод

Allows all users.
public static AllowAllUsers ( ISecured entity, string action, RockContext rockContext = null ) : void
entity ISecured The entity.
action string The action.
rockContext RockContext The rock context.
Результат void

AllowPerson() публичный статический Метод

Updates authorization rules for the entity so that the current person is allowed to perform the specified action.
public static AllowPerson ( ISecured entity, string action, Person person, RockContext rockContext = null ) : void
entity ISecured The entity.
action string The action.
person Person The person.
rockContext RockContext The rock context.
Результат void

AllowSecurityRole() публичный статический Метод

Allows the security role.
public static AllowSecurityRole ( ISecured entity, string action, Group group, RockContext rockContext = null ) : void
entity ISecured The entity.
action string The action.
group Group The group.
rockContext RockContext The rock context.
Результат void

AuthRules() публичный статический Метод

Returns the authorization rules for the specified entity and action.
public static AuthRules ( int entityTypeId, int entityId, string action ) : List
entityTypeId int The entity type id.
entityId int The entity id.
action string The action.
Результат List

Authorized() публичный статический Метод

Evaluates whether a selected person is allowed to perform the selected action on the selected entity.
public static Authorized ( ISecured entity, string action, Rock person ) : bool
entity ISecured The entity.
action string The action.
person Rock The person.
Результат bool

Authorized() публичный статический Метод

Evaluates whether a selected user is allowed to perform the selected action on the selected entity.
public static Authorized ( ISecured entity, string action, SpecialRole specialRole ) : bool
entity ISecured The entity.
action string The action.
specialRole SpecialRole The special role.
Результат bool

CopyAuthorization() публичный статический Метод

Copies the authorization.
public static CopyAuthorization ( ISecured sourceEntity, ISecured targetEntity ) : void
sourceEntity ISecured The source entity.
targetEntity ISecured The target entity.
Результат void

CopyAuthorization() публичный статический Метод

Copies the authorizations from one ISecured object to another
This method will save any previous changes made to the context
public static CopyAuthorization ( ISecured sourceEntity, ISecured targetEntity, RockContext rockContext, string action = "" ) : void
sourceEntity ISecured The source entity.
targetEntity ISecured The target entity.
rockContext RockContext The rock context.
action string Optional action (if ommitted or left blank, all actions will be copied).
Результат void

DecodeEntityTypeName() публичный статический Метод

Decodes the entity type name.
public static DecodeEntityTypeName ( string encodedTypeName ) : string
encodedTypeName string Name of the encoded type.
Результат string

EncodeEntityTypeName() публичный статический Метод

Encodes the entity type name for use in a URL
public static EncodeEntityTypeName ( Type iSecuredType ) : string
iSecuredType System.Type Type of the item to secure.
Результат string

EncodeEntityTypeName() публичный статический Метод

Encodes the entity type name for use in a URL
public static EncodeEntityTypeName ( string assemblyQualifiedName ) : string
assemblyQualifiedName string Assembly name of the item to secure.
Результат string

FindAuthRules() публичный статический Метод

Finds the auth rules.
public static FindAuthRules ( ISecured securableObject ) : IQueryable
securableObject ISecured The securable object.
Результат IQueryable

Flush() публичный статический Метод

Clear the static Authorizations object
public static Flush ( ) : void
Результат void

IsPrivate() публичный статический Метод

Determines whether the specified entity is private. Entity is considered private if only the current user has access. In this scenario, the first rule would give current user access, and second rule would deny all users.
public static IsPrivate ( ISecured entity, string action, Person person ) : bool
entity ISecured The entity.
action string The action.
person Person The person.
Результат bool

Load() публичный статический Метод

Load the static Authorizations object
public static Load ( ) : bool
Результат bool

MakePrivate() публичный статический Метод

Makes the entity private by setting up two authorization rules, one granting the selected person, and then another that denies all other users.
public static MakePrivate ( ISecured entity, string action, Person person, RockContext rockContext = null ) : void
entity ISecured The entity.
action string The action.
person Person The person.
rockContext RockContext The rock context.
Результат void

MakeUnPrivate() публичный статический Метод

Removes that two authorization rules that made the entity private.
public static MakeUnPrivate ( ISecured entity, string action, Person person, RockContext rockContext = null ) : void
entity ISecured The entity.
action string The action.
person Person The person.
rockContext RockContext The rock context.
Результат void

RefreshAction() публичный статический Метод

Reloads the action.
public static RefreshAction ( int entityTypeId, int entityId, string action, RockContext rockContext ) : void
entityTypeId int The entity type identifier.
entityId int The entity identifier.
action string The action.
rockContext RockContext The rock context.
Результат void

ReloadAction() публичный статический Метод

Reloads the action.
public static ReloadAction ( int entityTypeId, int entityId, string action ) : void
entityTypeId int The entity type identifier.
entityId int The entity identifier.
action string The action.
Результат void

ReloadAction() публичный статический Метод

Reloads the action.
public static ReloadAction ( int entityTypeId, int entityId, string action, RockContext rockContext ) : void
entityTypeId int The entity type identifier.
entityId int The entity identifier.
action string The action.
rockContext RockContext The rock context.
Результат void

ReloadEntity() публичный статический Метод

Reloads the entity.
public static ReloadEntity ( int entityTypeId, int entityId, RockContext rockContext = null ) : void
entityTypeId int The entity type identifier.
entityId int The entity identifier.
rockContext RockContext The rock context.
Результат void

SetAuthCookie() публичный статический Метод

Sets the auth cookie.
public static SetAuthCookie ( string userName, bool isPersisted, bool IsImpersonated ) : void
userName string Name of the user.
isPersisted bool if set to true [is persisted].
IsImpersonated bool if set to true [is impersonated].
Результат void