C# Class Rock.Security.Authorization

Static class for managing authorizations
Afficher le fichier Open project: SparkDevNetwork/Rock Class Usage Examples

Méthodes publiques

Méthode 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

Méthode 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 méthode

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.
Résultat void

AllowPerson() public static méthode

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.
Résultat void

AllowSecurityRole() public static méthode

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.
Résultat void

AuthRules() public static méthode

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.
Résultat List

Authorized() public static méthode

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.
Résultat bool

Authorized() public static méthode

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.
Résultat bool

CopyAuthorization() public static méthode

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

CopyAuthorization() public static méthode

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).
Résultat void

DecodeEntityTypeName() public static méthode

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

EncodeEntityTypeName() public static méthode

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.
Résultat string

EncodeEntityTypeName() public static méthode

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.
Résultat string

FindAuthRules() public static méthode

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

Flush() public static méthode

Clear the static Authorizations object
public static Flush ( ) : void
Résultat void

IsPrivate() public static méthode

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.
Résultat bool

Load() public static méthode

Load the static Authorizations object
public static Load ( ) : bool
Résultat bool

MakePrivate() public static méthode

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.
Résultat void

MakeUnPrivate() public static méthode

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.
Résultat void

RefreshAction() public static méthode

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.
Résultat void

ReloadAction() public static méthode

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.
Résultat void

ReloadAction() public static méthode

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.
Résultat void

ReloadEntity() public static méthode

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.
Résultat void

SetAuthCookie() public static méthode

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].
Résultat void