Source/NFX/Security/Permissions.cs
/// <summary>
/// Guards the action represented by enumerable of permissions by checking all permissions and throwing exception if
/// any of authorization attributes do not pass
/// </summary>
Guards the action represented by enumerable of permissions by checking all permissions and throwing exception if
any of authorization attributes do not pass
Guards the action represented by enumerable of permissions by checking all permissions and throwing exception if any of authorization attributes do not pass
public static void AuthorizeAndGuardAction(IEnumerable<Permission> permissions, string actionName, ISession session = null, GetSessionFunc getSessionFunc = null)
           {
             if (permissions==null) return;
             if (session==null && permissions.Any() && getSessionFunc!=null) session = getSessionFunc();
             var failed = permissions.FirstOrDefault(perm => !perm.Check(session));
             if (failed!=null)
               throw new AuthorizationException(string.Format(StringConsts.SECURITY_AUTHROIZATION_ERROR, failed,  actionName ?? CoreConsts.UNKNOWN));
           }
public static void AuthorizeAndGuardAction ( IEnumerable < Permission > permissions , string actionName , ISession session = null , GetSessionFunc getSessionFunc = null ) { if ( permissions == null ) return ; if ( session == null && permissions . Any ( ) && getSessionFunc != null ) session = getSessionFunc ( ) ; var failed = permissions . FirstOrDefault ( perm => ! perm . Check ( session ) ) ; if ( failed != null ) throw new AuthorizationException ( string . Format ( StringConsts . SECURITY_AUTHROIZATION_ERROR , failed , actionName ?? CoreConsts . UNKNOWN ) ) ; }
Guards the action represented by enumerable of permissions by checking all permissions and throwing exception if
any of authorization attributes do not pass
Guards the action represented by enumerable of permissions by checking all permissions and throwing exception if any of authorization attributes do not pass
permissions
IEnumerable<Permission>
actionName
string
session
ISession
getSessionFunc
GetSessionFunc