/// <summary> /// Define a user actor for a <see cref="ISecurable">securable</see> /// </summary> /// <param name="securable"><see cref="ISecurable"/> to secure</param> /// <returns>The <see cref="UserSecurityActor"/></returns> public static UserSecurityActor User(this ISecurable securable) { var actor = new UserSecurityActor(); securable.AddActor(actor); return actor; }
/// <summary> /// Initializes a new instance of <see cref="RoleRule"/> /// </summary> /// <param name="userToAuthorize">The <see cref="UserSecurityActor" /> to check the role against.</param> /// <param name="role">The role to check for</param> public RoleRule(UserSecurityActor userToAuthorize, string role) { _userToAuthorize = userToAuthorize; Role = role; }
/// <summary> /// Declares that the <see cref="UserSecurityActor"/> must be in a specific role /// </summary> /// <param name="securityActor"><see cref="UserSecurityActor"/> to declare it for</param> /// <param name="role">Role</param> /// <returns><see cref="UserSecurityActor"/> to continue the chain with</returns> public static UserSecurityActor MustBeInRole(this UserSecurityActor securityActor, string role) { securityActor.AddRule(new RoleRule(securityActor, role)); return(securityActor); }
/// <summary> /// Define a user actor for a <see cref="ISecurable">securable</see> /// </summary> /// <param name="securable"><see cref="ISecurable"/> to secure</param> /// <returns>The <see cref="UserSecurityActor"/></returns> public static UserSecurityActor User(this ISecurable securable) { var actor = new UserSecurityActor(Configure.Instance.Container.Get<ICanResolvePrincipal>()); securable.AddActor(actor); return actor; }