Table of Contents

Class AzureKeyVaultProvider

Namespace
Excalibur.Data.ElasticSearch.Security
Assembly
Excalibur.Data.ElasticSearch.Azure.dll

Azure Key Vault implementation of the Elasticsearch connection-credential store: OAuth tokens, service-account secrets, passwords, and API keys used to authenticate to Elasticsearch itself.

public sealed class AzureKeyVaultProvider : IElasticsearchKeyProvider, IElasticsearchKeyStorage, IElasticsearchKeyProviderEvents, IDisposable, IAsyncDisposable
Inheritance
AzureKeyVaultProvider
Implements
Inherited Members

Remarks

This is not encryption-key custody. Field-level encryption keys back onto Excalibur.Compliance.Azure's own Azure Key Vault-backed IKeyManagementProvider when a consumer opts in -- a structurally separate abstraction that returns key metadata, never key material.

Constructors

AzureKeyVaultProvider(IOptions<AzureKeyVaultOptions>, ILogger<AzureKeyVaultProvider>)

Initializes a new instance of the AzureKeyVaultProvider class.

public AzureKeyVaultProvider(IOptions<AzureKeyVaultOptions> options, ILogger<AzureKeyVaultProvider> logger)

Parameters

options IOptions<AzureKeyVaultOptions>

The Azure Key Vault configuration options.

logger ILogger<AzureKeyVaultProvider>

The logger for operational and security events.

Exceptions

ArgumentNullException

Thrown when required dependencies are null.

SecurityException

Thrown when Azure Key Vault connection cannot be established.

Methods

DeleteSecretAsync(string, CancellationToken)

Removes a secret from the key management system.

public Task<bool> DeleteSecretAsync(string keyName, CancellationToken cancellationToken)

Parameters

keyName string

The unique identifier for the secret to remove.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result contains true if the secret was removed successfully, false if the secret did not exist.

Exceptions

SecurityException

Thrown when secret deletion fails due to security constraints.

ArgumentException

Thrown when the key name is null, empty, or invalid.

Dispose()

Releases all resources used by the AzureKeyVaultProvider.

public void Dispose()

DisposeAsync()

Asynchronously releases resources, ensuring tracked timer callbacks have completed.

public ValueTask DisposeAsync()

Returns

ValueTask

GetSecretAsync(string, CancellationToken)

Retrieves a secret value from the secure key management system.

public Task<string?> GetSecretAsync(string keyName, CancellationToken cancellationToken)

Parameters

keyName string

The unique identifier for the secret to retrieve.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the secret value or null if the secret does not exist.

Exceptions

SecurityException

Thrown when secret retrieval fails due to security constraints.

ArgumentException

Thrown when the key name is null, empty, or invalid.

GetSecretMetadataAsync(string, CancellationToken)

Retrieves metadata about a secret without accessing the secret value itself.

public Task<SecretMetadata?> GetSecretMetadataAsync(string keyName, CancellationToken cancellationToken)

Parameters

keyName string

The unique identifier for the secret.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<SecretMetadata>

A task that represents the asynchronous operation. The task result contains the secret metadata or null if the secret does not exist.

Exceptions

SecurityException

Thrown when metadata retrieval fails due to security constraints.

ArgumentException

Thrown when the key name is null, empty, or invalid.

ListSecretsAsync(string?, bool, CancellationToken)

Lists all secrets managed by this provider, optionally filtered by prefix.

public Task<IReadOnlyList<SecretInfo>> ListSecretsAsync(string? prefix, bool includeMetadata, CancellationToken cancellationToken)

Parameters

prefix string

Optional prefix to filter secret names. If null, all secrets are returned.

includeMetadata bool

Whether to include metadata in the results.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<IReadOnlyList<SecretInfo>>

A task that represents the asynchronous operation. The task result contains the list of secret information matching the specified criteria.

Exceptions

SecurityException

Thrown when secret listing fails due to security constraints.

SecretExistsAsync(string, CancellationToken)

Checks whether a secret exists in the key management system without retrieving its value.

public Task<bool> SecretExistsAsync(string keyName, CancellationToken cancellationToken)

Parameters

keyName string

The unique identifier for the secret to check.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result contains true if the secret exists, false otherwise.

Exceptions

SecurityException

Thrown when secret existence check fails due to security constraints.

ArgumentException

Thrown when the key name is null, empty, or invalid.

SetSecretAsync(string, string, SecretMetadata?, CancellationToken)

Stores a secret value in the secure key management system.

public Task<bool> SetSecretAsync(string keyName, string secretValue, SecretMetadata? metadata, CancellationToken cancellationToken)

Parameters

keyName string

The unique identifier for the secret to store.

secretValue string

The secret value to store securely.

metadata SecretMetadata

Optional metadata associated with the secret.

cancellationToken CancellationToken

The cancellation token to monitor for cancellation requests.

Returns

Task<bool>

A task that represents the asynchronous operation. The task result contains true if the secret was stored successfully, false otherwise.

Exceptions

SecurityException

Thrown when secret storage fails due to security constraints.

ArgumentException

Thrown when the key name or secret value is invalid.

Events

SecretAccessed

Occurs when a secret is accessed, for audit and monitoring purposes.

public event EventHandler<SecretAccessedEventArgs>? SecretAccessed

Event Type

EventHandler<SecretAccessedEventArgs>