Created
June 13, 2022 21:24
-
-
Save mbaykara/754746c89e167e800890f993de37c6d4 to your computer and use it in GitHub Desktop.
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
| #!/bin/env bash | |
| FILE1=".creds/pub.json" | |
| if [ -f "$FILE1" ]; then | |
| echo "key pair exists, skipping key generation" | |
| else | |
| echo "Create public key and private key" | |
| step-cli crypto jwk create ./creds/pub.json ./creds/private.json --kty RSA | |
| echo "Create keyset" | |
| cat ./creds/pub.json | step-cli crypto jwk keyset add ./creds/keys.json | |
| sed -i 's/^/ /' ./creds/keys.json | |
| fi | |
| echo "Create signed JWT" | |
| export JWT=$(step-cli crypto jwt sign --key ./creds/private.json --iss "issuer@medium-jwt.mydomain.rocks" --aud "audience@medium-jwt.mydomain.rocks" --sub "subject@medium-jwt.mydomain.rocks" --iat $(date +%s) --exp $(date +%s -d 'now + 160 min') ) | |
| echo $JWT | |
| echo $JWT | step-cli crypto jwt verify --jwks ./creds/keys.json --iss "issuer@medium-jwt.mydomain.rocks" --aud "audience@medium-jwt.mydomain.rocks" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment