Beispiel #1
0
        public CustomPrincipal(IIdentity identity,
                               SimpleRoleClaim roleClaim)

            : base(identity, new List <string>().ToArray())
        {
            Role = roleClaim;
        }
Beispiel #2
0
        private bool IsInRole(ClaimsPrincipal claimsPrincipal)
        {
            SimpleRoleClaim item = claimsPrincipal.GetClaim <SimpleRoleClaim>("projectRequestRole");

            /*item is null when domain user makes a request without the bearer token. Which means that they are trying to hit the endpoint through a browser or that they haven't called /token first*/
            if (item == null || !Roles.Any(i => i.Trim().ToLower().Equals(item.Role.Trim().ToLower())))
            {
                return(false);
            }

            return(true);
        }