コード例 #1
0
        public static bool CanAccess(this IProvideMetadata type, IEnumerable <Claim> claimsPrincipalClaims)
        {
            var principalClaims = claimsPrincipalClaims.Where(x => x.Type == JwtClaimTypes.Role).ToArray();
            var isAdmin         = principalClaims.Any(x => x.Value == RoleManager.Admin.Name);

            if (isAdmin)
            {
                return(true);
            }
            var permissions = type.GetMetadata <IEnumerable <Activity> >(PermissionsKey, new List <Activity>());

            return(permissions.All(p =>
                                   principalClaims.Any(x => x.Value == UserClaimProvider.ToPolicyName(p))));
        }
コード例 #2
0
 public AuthorizeActivityAttribute(Activity activities) : base(UserClaimProvider.ToPolicyName(activities))
 {
     Activities = activities;
 }