Skip to content

Conversation

@amotl
Copy link
Member

@amotl amotl commented May 24, 2025

CrateDB 5.7.0 introduced JWT token authentication. Let's also implement it on the client sides.

/cc @matriv, @kneth

@coderabbitai
Copy link

coderabbitai bot commented May 24, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

JWT token authentication support was added to the CrateDB Python client. This includes updates to the connection and HTTP client classes to accept and pass JWT tokens, documentation and changelog updates, and new tests to verify JWT authentication behavior. Existing authentication mechanisms remain unchanged.

Changes

File(s) Change Summary
CHANGES.rst Updated changelog to mention the new JWT token authentication feature.
docs/connect.rst Added documentation and example for JWT token authentication in the connection setup.
src/crate/client/connection.py Extended Connection.__init__ to accept and document a jwt_token parameter.
src/crate/client/http.py Added jwt_token parameter to Client and Server for JWT authentication; sets Authorization header.
tests/client/test_http.py Enhanced test handler for "Bearer" JWT tokens; added/updated tests for JWT token authentication.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Connection
    participant Client
    participant Server

    User->>Connection: connect(jwt_token=...)
    Connection->>Client: __init__(jwt_token=...)
    Client->>Server: request(..., jwt_token=...)
    Server->>Server: Add Authorization: Bearer <jwt_token> header (if not set)
    Server-->>Client: Response
    Client-->>Connection: Response
    Connection-->>User: Connection established
Loading

Poem

In fields of code, a token hops—
JWT in paw, it never stops.
Now clients greet with bearer flair,
Securely bounding here and there.
The docs are plump, the tests are keen,
This rabbit’s code is fresh and clean!
🐇✨

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jwt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@amotl amotl requested review from seut and surister May 24, 2025 00:09
@amotl amotl marked this pull request as ready for review May 24, 2025 00:15
Copy link
Member

@seut seut left a comment

Choose a reason for hiding this comment

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

👍
Maybe adding a sanity check to give a good error if token and user/password auth is used in conjunction would be useful. Afaik, the user/password args would be used then instead (it will just override the Authorization header afaik) which may not be clear to a user.

@kneth
Copy link
Member

kneth commented Jun 2, 2025

Thank you for providing support for JWT!

@amotl amotl self-assigned this Oct 2, 2025
@surister
Copy link
Member

surister commented Dec 9, 2025

@amotl Hi, do you have time to wrap this up with Sebastian's suggestion or do you mind If I take over?

@amotl
Copy link
Member Author

amotl commented Dec 9, 2025

Hi @surister. Feel free to take over any time. Thank you. 🙏

@amotl amotl removed their assignment Dec 9, 2025
@amotl
Copy link
Member Author

amotl commented Dec 18, 2025

Hi. I just rebased the patch to make your job a bit easier. Thank you again.

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.

5 participants