FindAll() public method

Retrieves a IEnumerable{Claim} where each claim is matched by .
if 'match' is null.
public FindAll ( Predicate match ) : IEnumerable
match Predicate The function that performs the matching logic.
return IEnumerable
コード例 #1
0
        public static async Task<List<string>> GetGroups(ClaimsIdentity claimsId)
        {
            if (claimsId.FindFirst("_claim_names") != null
                && (Json.Decode(claimsId.FindFirst("_claim_names").Value)).groups != null)
                return await GetGroupsFromGraphAPI(claimsId);

            return claimsId.FindAll("groups").Select(c => c.Value).ToList();
        }
コード例 #2
0
ファイル: GraphUtil.cs プロジェクト: tandis/PnP
        /// <summary>
        /// For access check user's group membership must be determined. 
        /// This method retrieves user's group membership from Azure AD Graph API if not present in the token.
        /// </summary>
        /// <param name="claimsIdentity">The <see cref="ClaimsIdenity" /> object that represents the 
        /// claims-based identity of the currently signed in user and contains thier claims.</param>
        /// <returns>A list of ObjectIDs representing the groups that the user is member of.</returns>
        public static async Task<List<string>> GetMemberGroups(ClaimsIdentity claimsIdentity)
        {
            //check for groups overage claim. If present query graph API for group membership
            if (claimsIdentity.FindFirst("_claim_names") != null
                && (Json.Decode(claimsIdentity.FindFirst("_claim_names").Value)).groups != null)
                return await GetGroupsFromGraphAPI(claimsIdentity);

            return claimsIdentity.FindAll("groups").Select(c => c.Value).ToList();
        }
コード例 #3
0
 public static string FindUserKey(ClaimsIdentity claimsIdentity)
 {
     if (claimsIdentity == null)
     {
         throw new ArgumentNullException("claimsIdentity");
     }
     Claim nameIdentifierClaim = claimsIdentity.FindAll(ClaimTypes.NameIdentifier).SingleOrDefault();
     if (nameIdentifierClaim == null)
     {
         throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Claim type '{0}' was not found.", ClaimTypes.NameIdentifier));
     }
     return nameIdentifierClaim.Value;
 }
コード例 #4
0
        public static AuthenticationProperties CreateProperties(ClaimsIdentity identity)
        {
            var roleClaimValues = identity.FindAll(ClaimTypes.Role).Select(c => c.Value);

            var roles = string.Join(",", roleClaimValues);

            IDictionary<string, string> data = new Dictionary<string, string>
            {
                { "userName", identity.FindFirstValue(ClaimTypes.Name) },
                { "userRoles", roles }
            };

            return new AuthenticationProperties(data);
        }
コード例 #5
0
        public void Find_CaseInsensivity()
        {
            var claim_type = new Claim("TYpe", "value");
            var id         = new ClaimsIdentity(
                new[] { claim_type },
                "base_auth_type", "base_name_claim_type", null);

            var f1 = id.FindFirst("tyPe");

            Assert.Equal("value", f1.Value);

            var f2 = id.FindAll("tyPE").First();

            Assert.Equal("value", f2.Value);
        }
コード例 #6
0
 ///  <summary>
 ///
 ///  </summary>
 ///  <typeparam name="T"></typeparam>
 /// <param name="identity"></param>
 /// <param name="claimType"></param>
 ///  <returns></returns>
 public static IEnumerable <T> GetUserClaims <T>(this ClaimsIdentity identity, string claimType)
 => identity.FindAll(claimType).Select(x => (T)Convert.ChangeType(x.Value, typeof(T)));
コード例 #7
0
ファイル: ClaimsIdentityTest.cs プロジェクト: nlhepler/mono
		public void FindCaseInsensivity ()
		{
			var claim_type = new Claim("TYpe", "value");
			var id = new ClaimsIdentity (
				new[] { claim_type },
				"base_auth_type", "base_name_claim_type", null);

			var f1 = id.FindFirst ("tyPe");
			Assert.AreEqual ("value", f1.Value, "#1");

			var f2 = id.FindAll ("tyPE").First ();
			Assert.AreEqual ("value", f2.Value, "#2");
		}