Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit 20e6f79

Browse files
committed
examples: documentation & example of sending bad header
1 parent 8b65452 commit 20e6f79

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

example/jwt_test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
mkdir -p cloudflare_mock/cdn-cgi/access
44

5+
printf "\nGenerating Private Key & Certificate: \n"
56
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
67
-subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" \
78
-keyout certs/private.key -out certs/certificate.pem
89

910
CERT=$(cat certs/certificate.pem)
1011

12+
printf "\nAdding Certificate to JWKS Endpoint: \n"
1113
jq -n --arg cert "$CERT" '{public_certs: [{kid: "1", cert: $cert}, {kid: "2", cert: $cert}]}' \
12-
> cloudflare_mock/cdn-cgi/access/certs
14+
> cloudflare_mock/cdn-cgi/access/certs && echo "done"
1315

1416
docker-compose stop
1517
docker-compose up -d
@@ -38,8 +40,12 @@ done
3840
#wait a couple of seconds for the backends to start for haproxy
3941
sleep 3
4042

43+
printf "\nCURL Response with Bad Cf-Access-Jwt-Assertion header: \n"
44+
curl -H "Cf-Access-Jwt-Assertion: non-valid-token" localhost:8080
45+
4146
JWT_TOKEN=$(jwtgen -a RS256 -p certs/private.key --claims "$CLAIM")
4247

48+
printf "\nCURL Response with Valid Cf-Access-Jwt-Assertion header: \n"
4349
curl -H "Cf-Access-Jwt-Assertion: ${JWT_TOKEN}" localhost:8080
4450

4551
docker-compose stop

0 commit comments

Comments
 (0)