public void CanUserAccessKey(ClaimsPrincipal user, KeyStoreData key)
        {
            string email = null;

            user.ThrowIfNull(nameof(user));

            foreach (var claim in user.Claims)
            {
                if (claim.Type == EmailClaim)
                {
                    email = claim.Value;
                    break;
                }
                else if (claim.Type == UpnClaim)
                {
                    email = claim.Value;
                    break;
                }
            }

            if (email == null)
            {
                throw new System.ArgumentException("The email or upn claim is required");
            }

            if (!validEmails.Contains(email.Trim()))
            {
                throw new UnboundKeyStore.Models.KeyAccessException("User does not have access to the key");
            }
        }
示例#2
0
        public void CanUserAccessKey(ClaimsPrincipal user, KeyStoreData key)
        {
            user.ThrowIfNull(nameof(user));

            string sid = null;

            foreach (var claim in user.Claims)
            {
                if (claim.Type == SidClaim)
                {
                    sid = claim.Value;
                    break;
                }
            }

            if (sid == null)
            {
                throw new System.ArgumentException(SidClaim + " claim not found");
            }

            CanUserAccessKey(sid);
        }