Class SecureElasticsearchAuthenticationProvider
- Namespace
- Excalibur.Data.ElasticSearch.Security
- Assembly
- Excalibur.Data.ElasticSearch.dll
Provides secure authentication management for Elasticsearch connections with enterprise security features including credential rotation, validation, and integration with external key management systems.
public sealed class SecureElasticsearchAuthenticationProvider : IElasticsearchAuthenticationProvider, IAsyncDisposable, IDisposable
- Inheritance
-
SecureElasticsearchAuthenticationProvider
- Implements
- Inherited Members
Constructors
SecureElasticsearchAuthenticationProvider(IOptions<ElasticsearchSecurityOptions>, IElasticsearchKeyStorage, IHttpClientFactory, ILogger<SecureElasticsearchAuthenticationProvider>)
Initializes a new instance of the SecureElasticsearchAuthenticationProvider class.
public SecureElasticsearchAuthenticationProvider(IOptions<ElasticsearchSecurityOptions> securityOptions, IElasticsearchKeyStorage keyProvider, IHttpClientFactory httpClientFactory, ILogger<SecureElasticsearchAuthenticationProvider> logger)
Parameters
securityOptionsIOptions<ElasticsearchSecurityOptions>The security configuration options.
keyProviderIElasticsearchKeyStorageThe connection-credential store used to persist OAuth tokens, service-account secrets, passwords, and API keys.
httpClientFactoryIHttpClientFactoryThe HTTP client factory for OAuth2 token operations.
loggerILogger<SecureElasticsearchAuthenticationProvider>The logger for security events and diagnostics.
Exceptions
- ArgumentNullException
Thrown when required dependencies are null.
Properties
AuthenticationType
Gets the authentication type supported by this provider for security auditing and monitoring.
public ElasticsearchAuthenticationType AuthenticationType { get; }
Property Value
- ElasticsearchAuthenticationType
The authentication method type implemented by this provider.
SupportsRefresh
Gets a value indicating whether this authentication provider supports token refresh.
public bool SupportsRefresh { get; }
Property Value
- bool
True if the provider supports authentication token refresh, false otherwise.
SupportsRotation
Gets a value indicating whether this authentication provider supports credential rotation.
public bool SupportsRotation { get; }
Property Value
- bool
True if the provider supports automatic credential rotation, false otherwise.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
GetAuthenticationAsync(CancellationToken)
Retrieves the current authentication configuration for Elasticsearch client setup.
public Task<AuthenticationHeaderValue?> GetAuthenticationAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token to monitor for cancellation requests.
Returns
- Task<AuthenticationHeaderValue>
A task that represents the asynchronous operation. The task result contains the authentication configuration or null if authentication is not configured.
Exceptions
- SecurityException
Thrown when authentication credentials cannot be retrieved securely.
RefreshAuthenticationAsync(CancellationToken)
Refreshes expired or expiring authentication tokens to maintain continuous secure access.
public Task<bool> RefreshAuthenticationAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token to monitor for cancellation requests.
Returns
- Task<bool>
A task that represents the asynchronous operation. The task result contains true if the authentication was successfully refreshed, false if refresh is not supported or failed.
Exceptions
- SecurityException
Thrown when authentication refresh fails due to security constraints.
RotateCredentialsAsync(CancellationToken)
Rotates authentication credentials according to security policies and compliance requirements.
public Task<AuthenticationRotationResult> RotateCredentialsAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token to monitor for cancellation requests.
Returns
- Task<AuthenticationRotationResult>
A task that represents the asynchronous operation. The task result contains the rotation result indicating success, failure, or if rotation is not applicable.
Exceptions
- SecurityException
Thrown when credential rotation fails due to security constraints.
ValidateAuthenticationAsync(CancellationToken)
Validates that the current authentication credentials are valid and have not expired.
public Task<bool> ValidateAuthenticationAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token to monitor for cancellation requests.
Returns
- Task<bool>
A task that represents the asynchronous operation. The task result contains true if authentication is valid and active, false otherwise.
Exceptions
- SecurityException
Thrown when authentication validation fails due to security constraints.
Events
AuthenticationFailed
Occurs when authentication validation fails, enabling security monitoring and alerting.
public event EventHandler<AuthenticationFailedEventArgs>? AuthenticationFailed
Event Type
CredentialsRotated
Occurs when authentication credentials are rotated successfully.
public event EventHandler<AuthenticationRotatedEventArgs>? CredentialsRotated