Skip to content

Commit 7557e71

Browse files
authored
Add scitokens-generate-jwks CLI for key generation (#186)
1 parent ff132cf commit 7557e71

File tree

4 files changed

+405
-0
lines changed

4 files changed

+405
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
build
2+
_codeql_build_dir
3+
_codeql_detected_source_root
4+

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ target_link_libraries(scitokens-list-access SciTokens)
7575
add_executable(scitokens-create src/create.cpp)
7676
target_link_libraries(scitokens-create SciTokens)
7777

78+
add_executable(scitokens-generate-jwks src/generate_jwks.cpp)
79+
target_include_directories(scitokens-generate-jwks PRIVATE ${OPENSSL_INCLUDE_DIRS} ${LIBCRYPTO_INCLUDE_DIRS})
80+
target_link_libraries(scitokens-generate-jwks ${OPENSSL_LIBRARIES} ${LIBCRYPTO_LIBRARIES})
81+
7882
get_directory_property(TARGETS BUILDSYSTEM_TARGETS)
7983
install(
8084
TARGETS ${TARGETS}

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,30 @@ echo "<your_token_here>" | ./scitokens-verify
4242
Replace the given token above with the fresh one you just generated; using the above token should give an expired
4343
token error. The token must be provided via standard input (stdin).
4444

45+
Generating Keys for Testing
46+
----------------------------
47+
48+
For testing and development purposes, you can generate EC (ES256) key pairs using the `scitokens-generate-jwks` tool:
49+
50+
```
51+
./scitokens-generate-jwks --kid my-key-id --jwks jwks.json --private private.pem --public public.pem
52+
```
53+
54+
This generates:
55+
- `jwks.json`: A JWKS (JSON Web Key Set) file containing the public key
56+
- `public.pem`: The public key in PEM format
57+
- `private.pem`: The private key in PEM format
58+
59+
You can then create and verify tokens using these keys:
60+
61+
```
62+
# Create a token
63+
./scitokens-create --cred public.pem --key private.pem --keyid my-key-id --issuer https://my-issuer.example.com --claim "sub=testuser"
64+
65+
# Verify the token
66+
echo "<token>" | ./scitokens-verify --cred public.pem --issuer https://my-issuer.example.com --keyid my-key-id
67+
```
68+
4569
Instructions for Generating a Release
4670
-------------------------------------
4771

0 commit comments

Comments
 (0)