public static async Task <IEnumerable <GrantListEntry> > GetGrantsByKeyNameAsync(this KMSHelper kms, string keyName, string grantName, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken)) { var alias = await kms.GetKeyAliasByNameAsync(keyName, stringComparison, throwIfNotFound, cancellationToken); if (alias == null && !throwIfNotFound) { return(null); } var grants = await kms.ListGrantsAsync(alias.TargetKeyId, cancellationToken); return(grants.Where(x => x.GrantId.Equals(grantName, stringComparison) || x.Name.Equals(grantName, stringComparison))); }
public static async Task <CreateGrantResponse> CreateRoleGrantByName(this KMSHelper kms, string keyName, string grantName, string roleName, KMSHelper.GrantType grant, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken)) { var alias = await kms.GetKeyAliasByNameAsync(keyName, stringComparison, throwIfNotFound, cancellationToken); if (alias == null && !throwIfNotFound) { return new CreateGrantResponse() { HttpStatusCode = System.Net.HttpStatusCode.NotFound } } ; var role = await(new IAMHelper(kms._credentials)).GetRoleByNameAsync(roleName, StringComparison.InvariantCultureIgnoreCase, cancellationToken); return(await kms.CreateGrantAsync(grantName, alias.TargetKeyId, role.Arn, grant, cancellationToken)); }
public static async Task <GrantListEntry[]> GetGrantsByKeyNameAsync(this KMSHelper kms, string keyName, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase, bool throwIfNotFound = true, CancellationToken cancellationToken = default(CancellationToken)) { var alias = await kms.GetKeyAliasByNameAsync(keyName, stringComparison, throwIfNotFound, cancellationToken); return(await kms.ListGrantsAsync(alias.TargetKeyId, cancellationToken)); }