diff --git a/content/docs/tasks/security/authn-policy/index.md b/content/docs/tasks/security/authn-policy/index.md index f93a982ceb..739e739bb1 100644 --- a/content/docs/tasks/security/authn-policy/index.md +++ b/content/docs/tasks/security/authn-policy/index.md @@ -564,11 +564,24 @@ $ curl --header "Authorization: Bearer $TOKEN" $INGRESS_HOST/headers -s -o /dev/ {{< /text >}} To observe other aspects of JWT validation, use the script [`gen-jwt.py`]({{< github_tree >}}/security/tools/jwt/samples/gen-jwt.py) to -generate new tokens to test with different issuer, audiences, expiry date, etc. For example, the command below creates a token that +generate new tokens to test with different issuer, audiences, expiry date, etc. The script can be downloaded from the Istio repository: + +{{< text bash >}} +$ wget {{< github_file >}}/security/tools/jwt/samples/gen-jwt.py +$ chmod +x gen-jwt.py +{{< /text >}} + +You also need the `key.pem` file: + +{{< text bash >}} +$ wget {{< github_file >}}/security/tools/jwt/samples/key.pem +{{< /text >}} + +For example, the command below creates a token that expires in 5 seconds. As you see, Istio authenticates requests using that token successfully at first but rejects them after 5 seconds: {{< text bash >}} -$ TOKEN=$(@security/tools/jwt/samples/gen-jwt.py@ @security/tools/jwt/samples/key.pem@ --expire 5) +$ TOKEN=$(./gen-jwt.py ./key.pem --expire 5) $ for i in `seq 1 10`; do curl --header "Authorization: Bearer $TOKEN" $INGRESS_HOST/headers -s -o /dev/null -w "%{http_code}\n"; sleep 1; done 200 200