You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/cloudflare-one/identity/authorization-cookie/validating-json.mdx
+35-34Lines changed: 35 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,9 @@ pcx_content_type: how-to
3
3
title: Validate JWTs
4
4
sidebar:
5
5
order: 1
6
-
7
6
---
8
7
9
-
import { GlossaryTooltip } from"~/components"
8
+
import { GlossaryTooltip } from"~/components";
10
9
11
10
When Cloudflare sends a request to your origin, the request will include an [application token](/cloudflare-one/identity/authorization-cookie/application-token/) as a `Cf-Access-Jwt-Assertion` request header and as a `CF_Authorization` cookie.
12
11
@@ -22,9 +21,9 @@ You can also manually rotate the key using the [API](/api/resources/zero_trust/s
22
21
23
22
As shown in the example below, `https://<your-team-name>.cloudflareaccess.com/cdn-cgi/access/certs` contains two public keys: the current key used to sign all new tokens, and the previous key that has been rotated out.
24
23
25
-
*`keys`: both keys in JWK format
26
-
*`public_cert`: current key in PEM format
27
-
*`public_certs`: both keys in PEM format
24
+
-`keys`: both keys in JWK format
25
+
-`public_cert`: current key in PEM format
26
+
-`public_certs`: both keys in PEM format
28
27
29
28
```txt
30
29
{
@@ -65,9 +64,8 @@ As shown in the example below, `https://<your-team-name>.cloudflareaccess.com/cd
65
64
66
65
:::note[Avoid key rotation issues]
67
66
68
-
69
-
* Validate tokens using the external endpoint rather than saving the public key as a hard-coded value.
70
-
* Do not fetch the current key from `public_cert`, since your origin may inadvertently read an expired value from an outdated cache. Instead, match the `kid` value in the JWT to the corresponding certificate in `public_certs`.
67
+
- Validate tokens using the external endpoint rather than saving the public key as a hard-coded value.
68
+
- Do not fetch the current key from `public_cert`, since your origin may inadvertently read an expired value from an outdated cache. Instead, match the `kid` value in the JWT to the corresponding certificate in `public_certs`.
71
69
:::
72
70
73
71
## Verify the JWT manually
@@ -175,10 +173,10 @@ func main() {
175
173
176
174
`pip` install the following:
177
175
178
-
* flask
179
-
* requests
180
-
* PyJWT
181
-
* cryptography
176
+
- flask
177
+
- requests
178
+
- PyJWT
179
+
- cryptography
182
180
183
181
```python
184
182
from flask import Flask, request
@@ -251,8 +249,8 @@ if __name__ == '__main__':
251
249
### JavaScript example
252
250
253
251
```javascript
254
-
constexpress=require('express');
255
-
constjose=require('jose');
252
+
constexpress=require("express");
253
+
constjose=require("jose");
256
254
257
255
// The Application Audience (AUD) tag for your application
0 commit comments