From 20e6f79be77620e222f13a59e7678d1e7df45cc0 Mon Sep 17 00:00:00 2001 From: Bojan Zelic Date: Mon, 29 Jun 2020 11:00:15 -0700 Subject: [PATCH] examples: documentation & example of sending bad header --- example/jwt_test.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/example/jwt_test.sh b/example/jwt_test.sh index 2dc695c..6a91bfd 100755 --- a/example/jwt_test.sh +++ b/example/jwt_test.sh @@ -2,14 +2,16 @@ mkdir -p cloudflare_mock/cdn-cgi/access +printf "\nGenerating Private Key & Certificate: \n" openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \ -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" \ -keyout certs/private.key -out certs/certificate.pem CERT=$(cat certs/certificate.pem) +printf "\nAdding Certificate to JWKS Endpoint: \n" jq -n --arg cert "$CERT" '{public_certs: [{kid: "1", cert: $cert}, {kid: "2", cert: $cert}]}' \ - > cloudflare_mock/cdn-cgi/access/certs + > cloudflare_mock/cdn-cgi/access/certs && echo "done" docker-compose stop docker-compose up -d @@ -38,8 +40,12 @@ done #wait a couple of seconds for the backends to start for haproxy sleep 3 +printf "\nCURL Response with Bad Cf-Access-Jwt-Assertion header: \n" +curl -H "Cf-Access-Jwt-Assertion: non-valid-token" localhost:8080 + JWT_TOKEN=$(jwtgen -a RS256 -p certs/private.key --claims "$CLAIM") +printf "\nCURL Response with Valid Cf-Access-Jwt-Assertion header: \n" curl -H "Cf-Access-Jwt-Assertion: ${JWT_TOKEN}" localhost:8080 docker-compose stop \ No newline at end of file