Beispiel #1
0
        /// <summary>
        /// Select a second level value from the json user data with the given top level key name and second level sub key name and add it as a Claim.
        /// This no-ops if the keys are not found or the value is empty.
        /// </summary>
        /// <param name="collection">The <see cref="ClaimActionCollection"/>.</param>
        /// <param name="claimType">The value to use for Claim.Type when creating a Claim.</param>
        /// <param name="jsonKey">The top level key to look for in the json user data.</param>
        /// <param name="subKey">The second level key to look for in the json user data.</param>
        /// <param name="valueType">The value to use for Claim.ValueType when creating a Claim.</param>
        public static void MapJsonSubKey(this ClaimActionCollection collection, string claimType, string jsonKey, string subKey, string valueType)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            collection.Add(new JsonSubKeyClaimAction(claimType, valueType, jsonKey, subKey));
        }
        public static void MapScopes(this ClaimActionCollection collection, string claimType = "scope")
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            collection.Add(new CloudFoundryScopeClaimAction(claimType, ClaimValueTypes.String));
        }
Beispiel #3
0
        /// <summary>
        /// Delete all claims from the given ClaimsIdentity with the given ClaimType.
        /// </summary>
        /// <param name="collection">The <see cref="ClaimActionCollection"/>.</param>
        /// <param name="claimType">The claim type to delete</param>
        public static void DeleteClaim(this ClaimActionCollection collection, string claimType)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            collection.Add(new DeleteClaimAction(claimType));
        }
Beispiel #4
0
        /// <summary>
        /// Run the given resolver to select a value from the json user data to add as a claim.
        /// This no-ops if the returned value is empty.
        /// </summary>
        /// <param name="collection">The <see cref="ClaimActionCollection"/>.</param>
        /// <param name="claimType">The value to use for Claim.Type when creating a Claim.</param>
        /// <param name="valueType">The value to use for Claim.ValueType when creating a Claim.</param>
        /// <param name="resolver">The Func that will be called to select value from the given json user data.</param>
        public static void MapCustomJson(this ClaimActionCollection collection, string claimType, string valueType, Func <JsonElement, string?> resolver)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            collection.Add(new CustomJsonClaimAction(claimType, valueType, resolver));
        }
Beispiel #5
0
        /// <summary>
        /// Clears any current ClaimsActions and maps all values from the json user data as claims, excluding duplicates.
        /// </summary>
        /// <param name="collection">The <see cref="ClaimActionCollection"/>.</param>
        public static void MapAll(this ClaimActionCollection collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            collection.Clear();
            collection.Add(new MapAllClaimsAction());
        }
        /// <summary>
        /// Delete all claims from the ClaimsIdentity with the given claimTypes.
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="claimTypes"></param>
        public static void DeleteClaims(this ClaimActionCollection collection, params string[] claimTypes)
        {
            if (claimTypes == null)
            {
                throw new ArgumentNullException(nameof(claimTypes));
            }

            foreach (var claimType in claimTypes)
            {
                collection.Add(new DeleteClaimAction(claimType));
            }
        }
 /// <summary>
 /// Selects a top level value from the json user data with the given key name and adds it as a Claim.
 /// This no-ops if the ClaimsIdentity already contains a Claim with the given ClaimType.
 /// This no-ops if the key is not found or the value is empty.
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="claimType">The value to use for Claim.Type when creating a Claim.</param>
 /// <param name="jsonKey">The top level key to look for in the json user data.</param>
 /// <param name="valueType">The value to use for Claim.ValueType when creating a Claim.</param>
 public static void MapUniqueJsonKey(this ClaimActionCollection collection, string claimType, string jsonKey, string valueType)
 {
     collection.Add(new UniqueJsonKeyClaimAction(claimType, valueType, jsonKey));
 }
Beispiel #8
0
 public static void RemoveDuplicate(this ClaimActionCollection claimActions, string claimType)
 {
     claimActions.Add(new RemoveDuplicateClaimAction(claimType));
 }
Beispiel #9
0
 public static void MapJsonKeyMultiple(this ClaimActionCollection claimActions, string claimType, string jsonKey)
 {
     claimActions.Add(new MultipleClaimAction(claimType, jsonKey));
 }
 /// <summary>
 /// Clears any current ClaimsActions and maps all values from the json user data as claims, excluding duplicates.
 /// </summary>
 /// <param name="collection"></param>
 public static void MapAll(this ClaimActionCollection collection)
 {
     collection.Clear();
     collection.Add(new MapAllClaimsAction());
 }
 /// <summary>
 /// Run the given resolver to select a value from the json user data to add as a claim.
 /// This no-ops if the returned value is empty.
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="claimType">The value to use for Claim.Type when creating a Claim.</param>
 /// <param name="valueType">The value to use for Claim.ValueType when creating a Claim.</param>
 /// <param name="resolver">The Func that will be called to select value from the given json user data.</param>
 public static void MapCustomJson(this ClaimActionCollection collection, string claimType, string valueType, Func <JsonElement, string> resolver)
 {
     collection.Add(new CustomJsonClaimAction(claimType, valueType, resolver));
 }
 /// <summary>
 /// Delete all claims from the given ClaimsIdentity with the given ClaimType.
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="claimType"></param>
 public static void DeleteClaim(this ClaimActionCollection collection, string claimType)
 {
     collection.Add(new DeleteClaimAction(claimType));
 }
 public static void MapJsonKeyArray(this ClaimActionCollection collection, string claimType, string jsonKey)
 {
     collection.Add(new JsonKeyArrayClaimAction(claimType, null, jsonKey));
 }