Skip to content

Antalya 26.3: add --jwt-command to client#1809

Open
zvonand wants to merge 12 commits into
antalya-26.3from
feature/antalya-26.3/oauth-executable-token-in-client
Open

Antalya 26.3: add --jwt-command to client#1809
zvonand wants to merge 12 commits into
antalya-26.3from
feature/antalya-26.3/oauth-executable-token-in-client

Conversation

@zvonand
Copy link
Copy Markdown
Member

@zvonand zvonand commented May 18, 2026

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

clickhouse-client: added --jwt-command and --jwt-command-timeout, which invokes an external script to obtain a JWT for authentication; the script is re-invoked on every reconnect.

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All with Aarch64
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

@zvonand zvonand added port-antalya PRs to be ported to all new Antalya releases antalya-26.3 labels May 18, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

Workflow [PR], commit [de1a1c2]

@zvonand zvonand marked this pull request as ready for review May 22, 2026 11:24
@zvonand
Copy link
Copy Markdown
Member Author

zvonand commented May 22, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38da1d22e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread programs/client/Client.cpp Outdated
Comment thread programs/client/Client.cpp Outdated
zvonand and others added 3 commits May 22, 2026 14:01
…of github.com:Altinity/ClickHouse into feature/antalya-26.3/oauth-executable-token-in-client
@zvonand
Copy link
Copy Markdown
Member Author

zvonand commented May 22, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

if (config().has("jwt"))

P2 Badge Reject --login when jwt-command is configured

This guard only checks config().has("jwt"), so a jwt-command coming from config.xml is not treated as conflicting with --login. In that case the --login path can run the interactive OAuth flow and set a JWT, and only later main fails with "jwt-command and jwt cannot both be specified". The conflict should be detected here as well (checking jwt-command too) so users get an immediate BAD_ARGUMENTS error without side effects.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

zvonand and others added 3 commits May 27, 2026 22:20
Remove `goto` from `--login` handling, wrap conflict check in
`#if USE_JWT_CPP && USE_SSL` (fixes fast_test build), unbuffer
`--jwt-command` stderr so interactive prompts surface live, and
trim verbose comments.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zvonand
Copy link
Copy Markdown
Member Author

zvonand commented May 28, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45a1975f20

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Client/Connection.cpp
Comment on lines +159 to +164
else if (jwt_provider && JWTProvider::isJWT(jwt))
{
const Poco::Timestamp expiry = JWTProvider::getJwtExpiry(jwt);
const Poco::Timestamp refresh_threshold = Poco::Timestamp() + Poco::Timespan(30, 0);
if (expiry > Poco::Timestamp(0) && expiry < refresh_threshold)
jwt = jwt_provider->getJWT();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh JWTs before queries on live connections

When a client stays connected past a JWT's exp, this refresh path is never revisited because it only runs from Connection::connect; sendQuery now just reuses the already-open connection. The server records token expiry in the session and Session::checkIfUserIsStillValid throws USER_EXPIRED once it passes, so long-lived --login / --jwt-command sessions will start failing queries instead of fetching a fresh token and reconnecting as the removed sendQuery refresh did.

Useful? React with 👍 / 👎.

zvonand and others added 2 commits May 29, 2026 00:54
`Session::checkIfUserIsStillValid` ran on every query and terminated an
already-established session once the authenticating token passed its `exp`
(or once its token processor was removed by a config reload, M-28). For TCP
sessions this killed a live `clickhouse-client` connection mid-session, which
contradicts how password sessions behave: a session is validated only when it
is established (initial connect or reconnect), never re-checked per query.

Token expiry is still enforced where it belongs -- at `Session::authenticate`,
so an expired token can never establish or re-establish a session. This only
drops the per-query re-validation on a connection that is already up.

Revert the H-05 token-expiry binding and the M-28 processor-removal recheck,
keeping only the upstream `VALID UNTIL` enforcement (an explicit, opt-in admin
policy that applies to password sessions too). Removes the now-dead
`auth_token_expires_at` session field and the `hasTokenProcessor` helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Left over after removing the M-28 processor recheck.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

antalya antalya-26.3 port-antalya PRs to be ported to all new Antalya releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants