Example #1
0
        /// <summary>
        /// Delete a role
        /// </summary>
        /// <param name="role">The role object to delete</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <IdentityResult> DeleteAsync(DynamoDBRole role, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            await _dataAccess.DeleteRole(role, cancellationToken);

            return(IdentityResult.Success);
        }
Example #2
0
 /// <summary>
 /// Set a role's normalized name.
 /// </summary>
 /// <param name="role">The role in question</param>
 /// <param name="roleName">The desired role name</param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task SetRoleNameAsync(DynamoDBRole role, string roleName, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         cancellationToken.ThrowIfCancellationRequested();
         role.Name = roleName;
     }));
 }
Example #3
0
 /// <summary>
 /// Get the role's ID attribute
 /// </summary>
 /// <param name="role">The role</param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task <string> GetRoleIdAsync(DynamoDBRole role, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         cancellationToken.ThrowIfCancellationRequested();
         return role.Id;
     }));
 }
Example #4
0
 /// <summary>
 /// Get the role's normalized name attribute
 /// </summary>
 /// <param name="role">The role</param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task <string> GetNormalizedRoleNameAsync(DynamoDBRole role, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         cancellationToken.ThrowIfCancellationRequested();
         return role.NormalizedName;
     }));
 }
Example #5
0
 /// <summary>
 /// Add a claim to a role
 /// </summary>
 /// <param name="role">The role object</param>
 /// <param name="claim">The claim object</param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task AddClaimAsync(DynamoDBRole role, Claim claim, CancellationToken cancellationToken = default)
 {
     return(Task.Run(() =>
     {
         cancellationToken.ThrowIfCancellationRequested();
         role.ClaimTypes.Add(claim.Type);
         role.ClaimValues.Add(claim.Value);
     }));
 }
Example #6
0
 /// <summary>
 /// Remove a claim from a role.
 /// </summary>
 /// <param name="role">The role</param>
 /// <param name="claim"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task RemoveClaimAsync(DynamoDBRole role, Claim claim, CancellationToken cancellationToken = default)
 {
     return(Task.Run(() =>
     {
         cancellationToken.ThrowIfCancellationRequested();
         int index = role.ClaimTypes.IndexOf(claim.Type);
         role.ClaimTypes.Remove(claim.Type);
         role.ClaimValues.RemoveAt(index);
     }));
 }
Example #7
0
 /// <summary>
 /// Get the claims attached to a role.
 /// </summary>
 /// <param name="role">The role in question</param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task <IList <Claim> > GetClaimsAsync(DynamoDBRole role, CancellationToken cancellationToken = default)
 {
     return(Task.Run(() =>
     {
         cancellationToken.ThrowIfCancellationRequested();
         IList <Claim> Claims = new List <Claim>();
         for (int i = 0; i < role.ClaimTypes.Count; i++)
         {
             Claims.Add(new Claim(role.ClaimTypes[i], role.ClaimValues[i]));
         }
         return Claims;
     }));
 }
        /// <summary>
        /// Deletes a role from a DynamoDB table.
        /// </summary>
        /// <param name="role">The role in question</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <bool> DeleteRole(DynamoDBRole role, CancellationToken cancellationToken)
        {
            await _context.DeleteAsync(role, _roleStoreDBConfig, cancellationToken);

            return(true);
        }