Compare commits
	
		
			2 Commits
		
	
	
		
			38b63455d4
			...
			a97e4e2219
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a97e4e2219 | |||
| 35965591f5 | 
| @@ -22,7 +22,7 @@ namespace Core.Blueprint.KeyVault | |||||||
|         /// <returns> |         /// <returns> | ||||||
|         /// A <see cref="Tuple"/> containing a status message and a boolean indicating whether the secret was successfully deleted. |         /// A <see cref="Tuple"/> containing a status message and a boolean indicating whether the secret was successfully deleted. | ||||||
|         /// </returns> |         /// </returns> | ||||||
|         ValueTask<Tuple<string, bool>> DeleteSecretAsync(string secretName, CancellationToken cancellationToken); |         ValueTask<(string Message, bool Deleted)> DeleteSecretAsync(string secretName, CancellationToken cancellationToken); | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Retrieves a secret from Azure Key Vault. |         /// Retrieves a secret from Azure Key Vault. | ||||||
| @@ -33,7 +33,7 @@ namespace Core.Blueprint.KeyVault | |||||||
|         /// A <see cref="Tuple"/> containing the <see cref="KeyVaultResponse"/> with secret details  |         /// A <see cref="Tuple"/> containing the <see cref="KeyVaultResponse"/> with secret details  | ||||||
|         /// and an optional error message if the secret was not found. |         /// and an optional error message if the secret was not found. | ||||||
|         /// </returns> |         /// </returns> | ||||||
|         ValueTask<Tuple<KeyVaultResponse, string?>> GetSecretAsync(string secretName, CancellationToken cancellationToken); |         ValueTask<(KeyVaultResponse Secret, string? Message)> GetSecretAsync(string secretName, CancellationToken cancellationToken); | ||||||
|  |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Updates an existing secret in Azure Key Vault. If the secret does not exist, an error is returned. |         /// Updates an existing secret in Azure Key Vault. If the secret does not exist, an error is returned. | ||||||
| @@ -43,6 +43,6 @@ namespace Core.Blueprint.KeyVault | |||||||
|         /// <returns> |         /// <returns> | ||||||
|         /// A <see cref="Tuple"/> containing the updated <see cref="KeyVaultResponse"/> and an optional error message if the secret was not found. |         /// A <see cref="Tuple"/> containing the updated <see cref="KeyVaultResponse"/> and an optional error message if the secret was not found. | ||||||
|         /// </returns> |         /// </returns> | ||||||
|         ValueTask<Tuple<KeyVaultResponse, string>> UpdateSecretAsync(KeyVaultRequest newSecret, CancellationToken cancellationToken); |         ValueTask<(KeyVaultResponse Secret, string? Message)> UpdateSecretAsync(KeyVaultRequest newSecret, CancellationToken cancellationToken); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| using Azure.Security.KeyVault.Secrets; | using Azure.Security.KeyVault.Secrets; | ||||||
| using VaultSharp; |  | ||||||
| using VaultSharp.V1.AuthMethods.Token; |  | ||||||
| using Core.Blueprint.KeyVault.Configuration; | using Core.Blueprint.KeyVault.Configuration; | ||||||
| using Microsoft.Extensions.Configuration; | using Microsoft.Extensions.Configuration; | ||||||
| using System.Net.Http.Json; | using System.Net.Http.Json; | ||||||
|  | using VaultSharp; | ||||||
| using VaultSharp.Core; | using VaultSharp.Core; | ||||||
|  | using VaultSharp.V1.AuthMethods.Token; | ||||||
|  |  | ||||||
| namespace Core.Blueprint.KeyVault; | namespace Core.Blueprint.KeyVault; | ||||||
|  |  | ||||||
| @@ -67,7 +67,7 @@ public sealed class KeyVaultProvider : IKeyVaultProvider | |||||||
|     /// <returns> |     /// <returns> | ||||||
|     /// A <see cref="Tuple"/> containing a status message and a boolean indicating whether the secret was successfully deleted. |     /// A <see cref="Tuple"/> containing a status message and a boolean indicating whether the secret was successfully deleted. | ||||||
|     /// </returns> |     /// </returns> | ||||||
|     public async ValueTask<Tuple<string, bool>> DeleteSecretAsync(string secretName, CancellationToken cancellationToken) |     public async ValueTask<(string Message, bool Deleted)> DeleteSecretAsync(string secretName, CancellationToken cancellationToken) | ||||||
|     { |     { | ||||||
|         if (environment == "Local") |         if (environment == "Local") | ||||||
|         { |         { | ||||||
| @@ -88,7 +88,7 @@ public sealed class KeyVaultProvider : IKeyVaultProvider | |||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Retrieves a secret from Azure Key Vault or HashiCorp Vault. |     /// Retrieves a secret from Azure Key Vault or HashiCorp Vault. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     public async ValueTask<Tuple<KeyVaultResponse, string?>> GetSecretAsync(string secretName, CancellationToken cancellationToken) |     public async ValueTask<(KeyVaultResponse Secret, string? Message)> GetSecretAsync(string secretName, CancellationToken cancellationToken) | ||||||
|     { |     { | ||||||
|         if (environment == "Local") |         if (environment == "Local") | ||||||
|         { |         { | ||||||
| @@ -108,7 +108,7 @@ public sealed class KeyVaultProvider : IKeyVaultProvider | |||||||
|             } |             } | ||||||
|             catch (VaultSharp.Core.VaultApiException ex) when (ex.HttpStatusCode == System.Net.HttpStatusCode.NotFound) |             catch (VaultSharp.Core.VaultApiException ex) when (ex.HttpStatusCode == System.Net.HttpStatusCode.NotFound) | ||||||
|             { |             { | ||||||
|                 return new(new KeyVaultResponse(), "Key Not Found"); |                 return new(new KeyVaultResponse { }, "Key Not Found"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -126,7 +126,7 @@ public sealed class KeyVaultProvider : IKeyVaultProvider | |||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Updates an existing secret in Azure Key Vault or HashiCorp Vault. If the secret does not exist, an error is returned. |     /// Updates an existing secret in Azure Key Vault or HashiCorp Vault. If the secret does not exist, an error is returned. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     public async ValueTask<Tuple<KeyVaultResponse, string>> UpdateSecretAsync(KeyVaultRequest newSecret, CancellationToken cancellationToken) |     public async ValueTask<(KeyVaultResponse Secret, string? Message)> UpdateSecretAsync(KeyVaultRequest newSecret, CancellationToken cancellationToken) | ||||||
|     { |     { | ||||||
|         var existingSecret = await this.GetSecretAsync(newSecret.Name, cancellationToken); |         var existingSecret = await this.GetSecretAsync(newSecret.Name, cancellationToken); | ||||||
|         if (!string.IsNullOrEmpty(existingSecret.Item2)) |         if (!string.IsNullOrEmpty(existingSecret.Item2)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user