Skip to content

Commit

Permalink
tools: Show example of using tools
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Collins <[email protected]>
  • Loading branch information
benmcollins committed Jan 15, 2025
1 parent 15e6760 commit 7e73343
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
31 changes: 31 additions & 0 deletions tools/example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

KEY=jwt-test-key.bin
JWK=jwk-test-key.json

if [ ! -e "${KEY}" ]; then
echo Creating 512 bit binary random key
dd if=/dev/urandom bs=1 count=64 "of=${KEY}"
fi

if [ ! -e "$JWK" ]; then
echo Converting key to JWK
key2jwk -o "${JWK}" "${KEY}"
fi

TOKEN=jwt-test-token

echo Generating token
jwt-generate -k "${JWK}" \
-c s:group=staff \
-c b:admin=false \
-c s:iss=disk.swissdisk.com \
-c s:user=bcollins \
-c i:exp=1768402249 > ${TOKEN}

if command -v jq > /dev/null; then
JQ="--print=jq -C"
fi

echo Verifying token
cat ${TOKEN} | jwt-verify -k "${JWK}" "${JQ}" -v -
4 changes: 2 additions & 2 deletions tools/key2jwk.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Automatically generated by Pandoc 3.6.1
.\" Automatically generated by Pandoc 3.6.2
.\"
.TH "KEY2JWK" "1" "" "key2jwk User Manual" "LibJWT C Library"
.SH NAME
Expand Down Expand Up @@ -86,7 +86,7 @@ Disable generating \f[B]kid\f[R] attribute.
\f[B]\-m\f[R], \f[B]\-\-disable\-hmac\f[R]
Disable falling back to HAMC for key files that OpenSSL cannot read.
.TP
\f[B]\-o\f[R] \f[I]FILE\f[R], \f[B]\-\-json\f[R]=\f[I]FILE\f[R]
\f[B]\-o\f[R] \f[I]FILE\f[R], \f[B]\-\-output\f[R]=\f[I]FILE\f[R]
Use \f[I]FILE\f[R] to write the JWKS.
Use \f[B]\-\f[R] to write to stdout.
.SH BUGS
Expand Down
2 changes: 1 addition & 1 deletion tools/key2jwk.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Example output:
**\-m**, **\-\-disable-hmac**
~ Disable falling back to HAMC for key files that OpenSSL cannot read.

**\-o** _FILE_, **\-\-json**=_FILE_
**\-o** _FILE_, **\-\-output**=_FILE_
~ Use _FILE_ to write the JWKS. Use **-** to write to stdout.

# BUGS
Expand Down

0 comments on commit 7e73343

Please sign in to comment.