Beispiel #1
0
        public static bool CheckAccess(this IAuthorizationService authorizationService, IPrincipal principal, Operation operation, Resource resource)
        {
            var claimsPrincipal = principal.AsClaimsPrincipal();
            var resources       = new Collection <Claim>(new Claim[] { resource }.ToList());
            var operations      = new Collection <Claim>(new Claim[] { operation }.ToList());

            var authorizationContext = new AuthorizationContext(claimsPrincipal, resources, operations);

            return(authorizationService.CheckAccess(authorizationContext));
        }
        public static bool CheckAccess(this IAuthorizationService authorizationService, IPrincipal principal, Operation operation, Resource resource)
        {
            var claimsPrincipal = principal.AsClaimsPrincipal();
            var resources = new Collection<Claim>(new Claim[] { resource }.ToList());
            var operations = new Collection<Claim>(new Claim[] { operation }.ToList());

            var authorizationContext = new AuthorizationContext(claimsPrincipal, resources, operations);

            return authorizationService.CheckAccess(authorizationContext);
        }
 public static bool TryFindFirstClaim(this IPrincipal principal, Predicate <Claim> match, out Claim claim)
 {
     claim = principal.AsClaimsPrincipal().Claims.FirstOrDefault(c => match(c));
     return(claim != null);
 }