| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using Azure.Security.KeyVault.Secrets; |
| | 5 | | using Microsoft.Extensions.Configuration; |
| | 6 | |
|
| | 7 | | namespace Azure.Extensions.AspNetCore.Configuration.Secrets |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Default implementation of <see cref="KeyVaultSecretManager"/> that loads all secrets |
| | 11 | | /// and replaces '--' with ':" in key names. |
| | 12 | | /// </summary> |
| | 13 | | public class KeyVaultSecretManager |
| | 14 | | { |
| 0 | 15 | | internal static KeyVaultSecretManager Instance { get; } = new KeyVaultSecretManager(); |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// Checks if <see cref="KeyVaultSecret"/> value should be retrieved. |
| | 19 | | /// </summary> |
| | 20 | | /// <param name="secret">The <see cref="KeyVaultSecret"/> instance.</param> |
| | 21 | | /// <returns><code>true</code> if secrets value should be loaded, otherwise <code>false</code>.</returns> |
| | 22 | | public virtual string GetKey(KeyVaultSecret secret) |
| | 23 | | { |
| 36 | 24 | | return secret.Name.Replace("--", ConfigurationPath.KeyDelimiter); |
| | 25 | | } |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// Maps secret to a configuration key. |
| | 29 | | /// </summary> |
| | 30 | | /// <param name="secret">The <see cref="KeyVaultSecret"/> instance.</param> |
| | 31 | | /// <returns>Configuration key name to store secret value.</returns> |
| | 32 | | public virtual bool Load(SecretProperties secret) |
| | 33 | | { |
| 48 | 34 | | return true; |
| | 35 | | } |
| | 36 | | } |
| | 37 | | } |