Created
December 7, 2017 16:47
-
-
Save mvanholsteijn/7e94d7124e8438e95054a5f94c02da45 to your computer and use it in GitHub Desktop.
Add a Auth0 JWT plugin on an Kong API Gateway API
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
#!/bin/bash | |
DOMAIN=${1:-mvanholsteijn.eu.auth0.com} | |
KONG_API=http://localhost:8001 | |
PUBLIC_KEY=$(curl -sS https://${DOMAIN}/pem | openssl x509 -pubkey -noout) | |
[[ -z $PUBLIC_KEY ]] && echo "ERROR: could not retrieve public key of $PUBLIC_KEY" && exit 1 | |
# add user | |
curl -sS -i -X POST $KONG_API/consumers --data username=$DOMAIN | |
# add public key to consumer | |
curl -i -X POST $KONG_API/consumers/$DOMAIN/jwt \ | |
-F "algorithm=RS256" \ | |
-F "rsa_public_key=${PUBLIC_KEY}" \ | |
-F "key=https://$DOMAIN/" | |
# add an sample API | |
curl -i -X POST $KONG_API/apis \ | |
--data "name=headers" \ | |
--data "hostnames=httpbin.org" \ | |
--data "upstream_url=http://httpbin.org/anything" | |
# add the JWT plugin on the Sample API | |
curl -i -X POST $KONG_API/apis/headers/plugins \ | |
--data name=jwt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment