/// <summary> /// Creates a new instance of `<see cref="SecretCache"/>`. /// </summary> /// <param name="namespace">The namespace used to when reading, writing, or deleting secrets from the cache.</param> /// <param name="getTargetName">Delegate used to generate key names when reading, writing, or deleting secrets.</param> public SecretCache(RuntimeContext context, string @namespace, Secret.UriNameConversionDelegate getTargetName) : this(context) { if (string.IsNullOrWhiteSpace(@namespace)) { throw new ArgumentNullException(@namespace); } _namespace = @namespace; _getTargetName = getTargetName ?? Secret.UriToName; }
public KeyVaultSecretStore(RuntimeContext context, string @namespace, ICredentialStore credentialCache, string keyVaultUrl, bool?useMsi, string certAuthStoreType, string certAuthThumbprint, string certAuthClientId, Secret.UriNameConversionDelegate getTargetName) { if (context is null) { throw new ArgumentNullException(nameof(context)); } _context = context; if (@namespace is null) { throw new ArgumentNullException(nameof(@namespace)); } if (@namespace.IndexOfAny(BaseSecureStore.IllegalCharacters) != -1) { var inner = new FormatException("Namespace contains illegal characters."); throw new ArgumentException(inner.Message, nameof(@namespace), inner); } _getTargetName = getTargetName ?? Secret.UriToName; _namespace = @namespace; _credentialCache = credentialCache ?? new SecretCache(context, @namespace, _getTargetName); this._getTargetName = getTargetName; KeyVaultHelper.Config config = new KeyVaultHelper.Config() { KeyVaultUrl = keyVaultUrl, UseMsi = useMsi, CertificateThumbprint = certAuthThumbprint, CertificateStoreType = certAuthStoreType, ClientId = certAuthClientId }; KeyVaultHelper.Configure(config); }
/// <summary> /// Creates a new <see cref="SecretStore"/> backed by the operating system keychain / secrets vault. /// </summary> /// <param name="namespace">The namespace of the secrets written and read by this store.</param> /// <param name="credentialCache"> /// Write-through, read-first cache. Default cache is used if a custom cache is not provided. /// </param> /// <param name="tokenCache"> /// Write-through, read-first cache. Default cache is used if a custom cache is not provided. /// </param> /// <param name="getTargetName"> /// Delegate used to transform a `<see cref="TargetUri"/>` into a store lookup key. /// </param> public SecretStore( RuntimeContext context, string @namespace, ICredentialStore credentialCache, ITokenStore tokenCache, Secret.UriNameConversionDelegate getTargetName) : base(context) { if (string.IsNullOrWhiteSpace(@namespace)) { throw new ArgumentNullException(nameof(@namespace)); } if (@namespace.IndexOfAny(IllegalCharacters) != -1) { throw new ArgumentException("Namespace contains illegal characters.", nameof(@namespace)); } _getTargetName = getTargetName ?? Secret.UriToName; _namespace = @namespace; _credentialCache = credentialCache ?? new SecretCache(context, @namespace, _getTargetName); _tokenCache = tokenCache ?? new SecretCache(context, @namespace, _getTargetName); }
/// <summary> /// Creates a new <see cref="SecretStore"/> backed by the operating system keychain / secrets vault. /// </summary> /// <param name="namespace">The namespace of the secrets written and read by this store.</param> /// <param name="credentialCache">Write-through, read-first cache. Default cache is used if a custom cache is not provided.</param> /// <param name="tokenCache">Write-through, read-first cache. Default cache is used if a custom cache is not provided.</param> /// <param name="getTargetName">Delegate used to transform a `<see cref="TargetUri"/>` into a store lookup key.</param> public SecretStore( RuntimeContext context, string @namespace, ICredentialStore credentialCache, ITokenStore tokenCache, Secret.UriNameConversionDelegate getTargetName) : base(context) { if (@namespace is null) { throw new ArgumentNullException(nameof(@namespace)); } if (@namespace.IndexOfAny(IllegalCharacters) != -1) { var inner = new FormatException("Namespace contains illegal characters."); throw new ArgumentException(inner.Message, nameof(@namespace), inner); } _getTargetName = getTargetName ?? Secret.UriToName; _namespace = @namespace; _credentialCache = credentialCache ?? new SecretCache(context, @namespace, _getTargetName); _tokenCache = tokenCache ?? new SecretCache(context, @namespace, _getTargetName); }
public SecretStore(RuntimeContext context, string @namespace, Secret.UriNameConversionDelegate getTargetName) : this(context, @namespace, null, null, getTargetName) { }