Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT auth support #360

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

JWT auth support #360

wants to merge 4 commits into from

Conversation

slvrtrn
Copy link
Contributor

@slvrtrn slvrtrn commented Nov 29, 2024

Summary

  • Support for JWT tokens auth is added (an upcoming feature in ClickHouse Cloud). Closes Add JWT support #270
  • Top-level username and password options in the config are now deprecated; the auth object should be used instead.
  • Supported via the URL configuration as the access_token param.
  • It is possible to override JWT token for a particular request, too.
  • The related tests are ignored until we have an instance with JWT support.

The URL config example needs to be updated - maybe later as a follow-up.

Checklist

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@slvrtrn slvrtrn requested a review from mshustov November 29, 2024 17:51
Copy link

sonarcloud bot commented Nov 29, 2024

@slvrtrn
Copy link
Contributor Author

slvrtrn commented Nov 29, 2024

82.9% Coverage on New Code

It should increase once the related tests are enabled.

packages/client-common/src/config.ts Show resolved Hide resolved
...this.defaultHeaders,
Authorization: `Basic ${Buffer.from(`${params.auth.username}:${params.auth.password}`).toString('base64')}`,
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

optional: can we move Auth header calculation logic to a separate function and test separately? It's hard to reason about the flow with a few levels of if

if (isJWTAuth(params?.auth)) {...}
if (this.params.set_basic_auth_header) {
      if (isCredentialsAuth(params?.auth)) { ... } 
      else {...}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JWT support
2 participants