C# Class Rock.Security.Authorization

Static class for managing authorizations
Datei anzeigen Open project: SparkDevNetwork/Rock Class Usage Examples

Public Methods

Method Description
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.

Private Methods

Method Description
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.

Method Details

AllowAllUsers() public static method

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.
return void

AllowPerson() public static method

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.
return void

AllowSecurityRole() public static method

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.
return void

AuthRules() public static method

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.
return List

Authorized() public static method

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.
return bool

Authorized() public static method

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.
return bool

CopyAuthorization() public static method

Copies the authorization.
public static CopyAuthorization ( ISecured sourceEntity, ISecured targetEntity ) : void
sourceEntity ISecured The source entity.
targetEntity ISecured The target entity.
return void

CopyAuthorization() public static method

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).
return void

DecodeEntityTypeName() public static method

Decodes the entity type name.
public static DecodeEntityTypeName ( string encodedTypeName ) : string
encodedTypeName string Name of the encoded type.
return string

EncodeEntityTypeName() public static method

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.
return string

EncodeEntityTypeName() public static method

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.
return string

FindAuthRules() public static method

Finds the auth rules.
public static FindAuthRules ( ISecured securableObject ) : IQueryable
securableObject ISecured The securable object.
return IQueryable

Flush() public static method

Clear the static Authorizations object
public static Flush ( ) : void
return void

IsPrivate() public static method

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.
return bool

Load() public static method

Load the static Authorizations object
public static Load ( ) : bool
return bool

MakePrivate() public static method

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.
return void

MakeUnPrivate() public static method

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.
return void

RefreshAction() public static method

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.
return void

ReloadAction() public static method

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.
return void

ReloadAction() public static method

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.
return void

ReloadEntity() public static method

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.
return void

SetAuthCookie() public static method

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].
return void