Skip to content

Commit 67f51fd

Browse files
committed
updated change log and methods documentation
1 parent 1e4f5ec commit 67f51fd

3 files changed

Lines changed: 30 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
## 0.9.9
22

3+
### Breaking Changes
4+
5+
- **[client-v2]** `Client.Builder#build()` now throws `ClientMisconfigurationException` instead of `IllegalArgumentException` for authentication and SSL misconfiguration (missing credentials, conflicting authentication methods, missing client certificate when SSL authentication is enabled, and trust store used together with a client certificate). Callers that relied on catching `IllegalArgumentException` from `build()` for these cases must catch `ClientMisconfigurationException` (which extends `RuntimeException` via `ClientException`).
6+
7+
- **[client-v2]** Combining `setUsername(...)` + `setPassword(...)` with a custom `Authorization` HTTP header (`httpHeader(HttpHeaders.AUTHORIZATION, ...)`) now fails at `Client.Builder#build()` with `ClientMisconfigurationException` unless HTTP Basic authentication is explicitly disabled via `useHTTPBasicAuth(false)`. Previously this combination was accepted and the custom `Authorization` header overrode the ClickHouse user/password headers at request time.
8+
9+
- **[client-v2]** The `access_token` configuration property (set via `Client.Builder#setAccessToken(String)` or directly through `setOption`) is now actually applied to outgoing requests as the `Authorization` HTTP header value verbatim. Previously the value was stored under `access_token` but never sent on the wire, so providing it alone had no effect on authentication. Callers must include the scheme prefix themselves (e.g. `setAccessToken("Bearer <token>")`), or use `useBearerTokenAuth(String)` which prepends `Bearer ` automatically.
10+
11+
- **[client-v2]** `Client.Builder#useBearerTokenAuth(String)` now stores the bearer token under the `access_token` configuration key (with the `Bearer ` prefix) instead of writing it directly into `http_header_authorization`. The HTTP wire format is unchanged, but the token is no longer observable through `Client#getReadOnlyConfig()` under the `http_header_authorization` key.
12+
313
### New Features
414

15+
- **[client-v2]** Added runtime credential update APIs on `Client`: `updateUserAndPassword(String, String)`, `updateAccessToken(String)`, and `updateBearerToken(String)`. Subsequent requests on the same `Client` instance use the new credentials without rebuilding the client. The authentication method is fixed at construction time; calling a runtime updater that does not match the configured method throws `ClientMisconfigurationException`. See `docs/authentication.md` for details and migration guidance.
16+
517
- **[jdbc-v2]** Added `cluster_name` configuration property to specify a target cluster for statements like `KILL QUERY` that require an `ON CLUSTER` clause to execute across all nodes. (https://github.com/ClickHouse/clickhouse-java/issues/2837)
618

719
### Bug Fixes

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,7 +2101,8 @@ public String toString() {
21012101
}
21022102

21032103
/**
2104-
* Returns unmodifiable map of configuration options.
2104+
* Returns unmodifiable map of initial configuration options.
2105+
* As authentication configuration values can change this map doesn't reflect them.
21052106
* @return - configuration options
21062107
*/
21072108
public Map<String, String> getConfiguration() {
@@ -2197,7 +2198,7 @@ public void updateBearerToken(String bearer) {
21972198
}
21982199

21992200
/**
2200-
* Updates the user & password for all subsequential requests.
2201+
* Updates the user and password for all subsequential requests.
22012202
* This method is not thread-safe with respect to other credential updates
22022203
* or concurrent request execution. Applications must coordinate access if
22032204
* they require stronger consistency.

client-v2/src/main/java/com/clickhouse/client/api/internal/CredentialsManager.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import java.util.Arrays;
88
import java.util.HashMap;
99
import java.util.Map;
10-
import java.util.concurrent.ConcurrentHashMap;
10+
import java.util.Objects;
11+
import java.util.concurrent.atomic.AtomicReference;
1112

1213
/**
1314
* Manages mutable authentication-related client settings.
@@ -20,21 +21,19 @@ public class CredentialsManager {
2021
ClientConfigProperties.httpHeader(HttpHeaders.AUTHORIZATION);
2122
public static final String AUTH_HEADER_BEARER_PREFIX = "Bearer ";
2223

23-
private final Map<String, Object> authConfig = new ConcurrentHashMap<>();
24-
25-
private final boolean sslAuthEnabled;
24+
private final AtomicReference<Map<String, Object>> authConfig = new AtomicReference<>();
2625

2726
private final boolean hasUserPassword;
2827

2928
private final boolean hasAccessToken;
3029

31-
private final boolean hasAuthHeader;
32-
3330
public CredentialsManager(Map<String, String> config) {
3431
this.hasUserPassword = isUserPassword(config);
3532
this.hasAccessToken = isAccessToken(config);
36-
this.sslAuthEnabled = isSslAuth(config);
37-
this.hasAuthHeader = isCustomAuthHeader(config);
33+
34+
boolean sslAuthEnabled = isSslAuth(config);
35+
boolean hasAuthHeader = isCustomAuthHeader(config);
36+
3837
final long authMethodsCount = Arrays
3938
.stream(new Boolean[] {hasUserPassword, hasAccessToken, sslAuthEnabled, hasAuthHeader})
4039
.filter(b-> b).count();
@@ -74,7 +73,8 @@ public boolean isHasUserPassword() {
7473
}
7574

7675
public void applyCredentials(Map<String, Object> target) {
77-
target.putAll(authConfig);
76+
Map<String, Object> properties = authConfig.get();
77+
target.putAll(properties);
7878
}
7979

8080
/**
@@ -98,10 +98,12 @@ public void setAccessToken(String accessToken) {
9898
}
9999

100100
private void updateBackedConfig(String username, String password, boolean useSslAuth, String authHeader) {
101-
authConfig.put(ClientConfigProperties.USER.getKey(), username);
102-
authConfig.put(ClientConfigProperties.PASSWORD.getKey(), password);
103-
authConfig.put(ClientConfigProperties.SSL_AUTH.getKey(), useSslAuth);
104-
authConfig.put(AUTHORIZATION_HEADER_KEY, authHeader);
101+
Map<String, Object> updated = new HashMap<>();
102+
updated.put(ClientConfigProperties.USER.getKey(), username);
103+
updated.put(ClientConfigProperties.PASSWORD.getKey(), password);
104+
updated.put(ClientConfigProperties.SSL_AUTH.getKey(), useSslAuth);
105+
updated.put(AUTHORIZATION_HEADER_KEY, authHeader);
106+
authConfig.set(updated);
105107
}
106108

107109
private static final String NO_AUTH_ERR_MSG = "Auth configuration is missing. At least one the following should be provided: " +

0 commit comments

Comments
 (0)