-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ben Collins <[email protected]>
- Loading branch information
1 parent
15e6760
commit 7e73343
Showing
3 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,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 - |
This file contains 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 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