-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👻 add hack to generate jwt token. (#534)
Add hack script to generate jwt tokens for _builtin_ auth. Likley used by actors such as the operator for migration related to upgrade. Related: - auth.Validator signature changed to return error. This is more flexible and _failures_ can be propagated. - auth.Builtin.Authenticate() returns NotAuthenticated when should have returned NotValid for clearity. - auth.NotValid includes `Reason`. --------- Signed-off-by: Jeff Ortel <[email protected]>
- Loading branch information
Showing
4 changed files
with
104 additions
and
31 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
# | ||
# Usage: jwt.sh <key> <scope> | ||
# | ||
# scope - (string) space-separated scopes. (default: *:*). | ||
# | ||
key=$1 | ||
scope="${2:-*:*}" | ||
header='{"typ":"JWT","alg":"HS512"}' | ||
payload="{\"user\":\"operator\",\"scope\":\"${scope}\"}" | ||
headerStr=$(echo -n ${header} \ | ||
| base64 -w 0 \ | ||
| sed s/\+/-/g \ | ||
| sed 's/\//_/g' \ | ||
| sed -E s/=+$//) | ||
payloadStr=$(echo -n ${payload} \ | ||
| base64 -w 0 \ | ||
| sed s/\+/-/g \ | ||
| sed 's/\//_/g' \ | ||
| sed -E s/=+$//) | ||
signStr=$(echo -n "${headerStr}.${payloadStr}" \ | ||
| openssl dgst -sha512 -hmac ${key} -binary \ | ||
| base64 -w 0 \ | ||
| sed s/\+/-/g \ | ||
| sed 's/\//_/g' \ | ||
| sed -E s/=+$//) | ||
token="${headerStr}.${payloadStr}.${signStr}" | ||
echo "${token}" |
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