-
Notifications
You must be signed in to change notification settings - Fork 22
Add scitokens-generate-jwks CLI for key generation #186
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
Conversation
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
…tring literal cast Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
…management Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
…ream Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
|
@copilot - please fix the linter issues. |
bbockelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - please address code review items.
src/generate_jwks.cpp
Outdated
|
|
||
| const char short_options[] = "hk:j:p:P:"; | ||
|
|
||
| std::string g_kid = "key-es256"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not specified, generate the keyid by taking a fingerprint of the public key, converting it to hex, and taking the first 8 characters. This makes the generated key ID more unique.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in commit dbe9088. The key ID is now auto-generated from the SHA256 fingerprint of the public key (first 8 hex characters) when not specified via --kid option.
src/generate_jwks.cpp
Outdated
| // Write private key PEM | ||
| std::unique_ptr<BIO, decltype(&BIO_free_all)> priv_bio(BIO_new_file( | ||
| g_private_file.c_str(), "w"), | ||
| BIO_free_all); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The private key needs special code to ensure it is written with mode 0600 so others cannot read it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit dbe9088. Private key file is now created with mode 0600 using open() with O_CREAT before writing, ensuring only the owner can read/write the file.
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
Fixed in commit 5c351b3. Applied clang-format to resolve all formatting issues. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
… key permissions - Auto-generate key ID from SHA256 hash of public key (first 8 hex chars) if not specified - Set private key file permissions to 0600 for security - Update usage text to reflect auto-generated key ID default Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
bbockelm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Implementation Complete: JWKS Creation CLI ✅
This PR adds a new CLI tool
scitokens-generate-jwksthat generates EC (ES256) key pairs and exports them in JWKS and PEM formats, eliminating the need for Python libraries in integration tests.Features
Changes
src/generate_jwks.cpp(365 lines)CMakeLists.txt- added build targetREADME.md- added usage documentation.gitignore- excluded build artifactsCode Quality
All code review feedback addressed:
Testing
Usage Example
Ready for merge - All requirements met, code review feedback addressed, tests passing.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.