Repository navigation
[client-v2,jdbc-2] JWT Support #3099
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3b184ef
added workflow update
chernser 3137835
Updated JWT tests in JDBC and client
chernser ed8148c
Enabled Cloud tests after compile
chernser 9b61ec0
Fixed JWT variable in build workflow
chernser 39c2f24
Trying another clous instance
chernser 8a2ddc9
Reverted using another instance for cloud tests
chernser 02ce89d
Added note to client docs about JWT for HTTP
chernser f208372
Merge branch 'main' into 09/02/26/jwt_example_docs
chernser c7a9b09
Merge branch 'main' into 09/02/26/jwt_example_docs
chernser b2df884
Added general documentation about JWT to integration spec
chernser f899f5c
locked dependenciew in requirement.txt for JWT script
chernser f174fb6
fixed JWT docs
chernser 96d0afd
Fix python setup in the CI
chernser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "keys": [ | ||
| { | ||
| "e": "AQAB", | ||
| "kid": "ZoA8VvkIi_fBxd5DEx9xekutcCztcanNFIHOTQp5aDo", | ||
| "kty": "RSA", | ||
| "n": "q-qV7VPWHe0-Pj-sgmq0_szurrPPwAsq3BPTllfFNQcQq5967SdS5jiCKhpVKYeXng468e9yimOMPzLIVBoCkV9ul9ruZDDJiPBoQ-_Pp5IuQQWTFUmnJ-ONkczVdb-FdkfQz4z1NVz_blCdOVyVPmeE9gh1S1V4g3kQazznwxKgOlJM4mO23j8xOmhGIL0w1IktP09vqicZoOsq3-RgN0x6jXdiv5Bn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LuUwODvQJviFUzEM9q7I9fLANPVkhY/SJ2/hl1ftxqxNFAH8mVzUbBNb2DMDc30eicHvsJUg0bqKoB5pLciyYqFsyA9z0x8ZaVpPVbXnVOHbzilp0jnhHeyLr+JCYH2UKfH/zFjxvcMP/q3M+HHCYyHXgdhMIFGBRE7xUMZjRnir28aUyet6hB5iV4wM8Yjd2mVaAsYtPqY8GnQxISzhUJ9rugie" | ||
| ] | ||
| } | ||
| ] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| __pycache__ | ||
| .venv | ||
| *.token | ||
| *.json | ||
| *.pem |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import os | ||
| import sys | ||
| import time | ||
|
|
||
| from jwcrypto.jwk import JWK | ||
| from jwcrypto.jwt import JWT | ||
|
|
||
|
|
||
| def get_private_key_pem(private_key_pem=None): | ||
| """Retrieve private key PEM string from parameter or JWT_PKEY environment variable.""" | ||
| pkey = private_key_pem or os.getenv("JWT_PKEY") | ||
| if pkey: | ||
| return pkey | ||
|
|
||
| raise ValueError( | ||
| "Private key not found. Please set JWT_PKEY environment variable." | ||
| ) | ||
|
|
||
|
|
||
| def generate_jwt_token( | ||
| private_key_pem=None, | ||
| audience="ci-test-service", | ||
| issuer="mydomain.com", | ||
| subject="ci-test", | ||
| expiration_seconds=600, # Valid for 10 minutes by default | ||
| output_file=None, | ||
| ): | ||
| """Generate a signed JWT token valid for a few minutes using the private key.""" | ||
| private_key_pem = get_private_key_pem(private_key_pem) | ||
| jwk_key = JWK.from_pem(private_key_pem.encode("utf-8")) | ||
|
|
||
| now = int(time.time()) | ||
| payload = { | ||
| "iss": issuer, | ||
| "sub": subject, | ||
| "aud": audience, | ||
| "iat": now, | ||
| "exp": now + expiration_seconds, | ||
| } | ||
|
|
||
| header = { | ||
| "alg": "RS256", | ||
| "typ": "JWT", | ||
| "kid": jwk_key.key_id, | ||
| } | ||
|
|
||
| token = JWT(header=header, claims=payload) | ||
| token.make_signed_token(jwk_key) | ||
| jwt_str = token.serialize() | ||
|
|
||
| if output_file: | ||
| with open(output_file, "w", encoding="utf-8") as f: | ||
| f.write(jwt_str) | ||
|
|
||
| return jwt_str | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| out_file = sys.argv[1] if len(sys.argv) > 1 else "jwt.token" | ||
| generate_jwt_token(output_file=out_file) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| jwcrypto==1.6.0 | ||
|
|
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.