Add credential rotation - #600
Open
DanielBunting wants to merge 3 commits into
Open
Conversation
…ation # Conflicts: # ClickHouse.Driver/ADO/ClickHouseClientSettings.cs # ClickHouse.Driver/ClickHouseClient.cs # RELEASENOTES.md
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class support for credential rotation in the .NET ClickHouse driver by introducing a per-request credentials callback on ClickHouseClientSettings, allowing long-lived clients/connections to pick up rotated Basic or Bearer credentials without recreating HTTP infrastructure (fixes #395).
Changes:
- Add
ClickHouseClientSettings.CredentialsProvider(Func<ClickHouseCredentials>) and a newClickHouseCredentialstype with factory helpers for Basic/Bearer auth. - Update request auth header application to honor precedence: per-query
BearerTokenoverride > provider result > staticBearerToken> staticUsername/Password(and treat empty per-query bearer token as “unset”). - Add unit + integration tests validating precedence and real password rotation behavior; update public API tracking and changelog fragment.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ClickHouse.Driver/QueryOptions.cs | Clarifies doc precedence for per-query bearer token vs client-level auth settings. |
| ClickHouse.Driver/PublicAPI/PublicAPI.Unshipped.txt | Records the new public API surface (CredentialsProvider, ClickHouseCredentials). |
| ClickHouse.Driver/ClickHouseCredentials.cs | Introduces a dedicated immutable credentials carrier with Basic/Bearer factories. |
| ClickHouse.Driver/ClickHouseClient.cs | Centralizes and extends auth header logic to evaluate provider per request. |
| ClickHouse.Driver/ADO/ClickHouseCommand.cs | Updates command bearer-token override documentation to include CredentialsProvider. |
| ClickHouse.Driver/ADO/ClickHouseClientSettings.cs | Adds the CredentialsProvider setting, copies/equality/hash updates, and documents precedence/behavior. |
| ClickHouse.Driver.Tests/ADO/CredentialsProviderTests.cs | Unit tests verifying precedence, per-request invocation, null fallback, and exception propagation. |
| ClickHouse.Driver.Tests/ADO/CredentialsProviderRotationTests.cs | Integration tests validating live password rotation scenarios for both ADO and ClickHouseClient. |
| ClickHouse.Driver.Tests/ADO/ClickHouseClientSettingsTests.cs | Tests equality/hash/copy semantics when CredentialsProvider is set. |
| changelog.d/395-credential-rotation.features.md | Changelog fragment describing the new credentials rotation feature and edge-case behavior change. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #395
Prior to this change, credentials were fixed at client construction. If a credential rotated, the only options are recreating the client, or patching the underlying http infrastructure and over-writing the auth header per request.
This change adds
ClickHouseClientSettings.CredentialsProvider- aFunc<ClickHouseCredentials>that is run once per HTTP request, before the auth header is set.Example:
Checklist
Delete items not relevant to your PR: