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: docs/auth/jwt/jwt-configuration.mdx
+73-53
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Example JSON Web Token (JWT) payload configuration definition:
23
23
24
24
```yaml title="globals/metadata/auth-config.hml"
25
25
kind: AuthConfig
26
-
version: v2
26
+
version: v3
27
27
definition:
28
28
mode:
29
29
jwt:
@@ -135,12 +135,13 @@ your auth provider.
135
135
136
136
### claimsConfig
137
137
138
-
You can specify where the engine should look for the claims within the decoded token either with one of `namespace` and `locations` options.
138
+
You can specify where the engine should look for the claims within the decoded token either with one of `namespace` and
139
+
`locations`options.
139
140
140
141
#### namespace {#jwt-claims-config-namespace}
141
142
142
-
The `namespace` option is used when all of the Hasura claims are present in a single object within the decoded JWT.
143
-
Our example uses `claims.jwt.hasura.io` in the [Example Decoded Payload](#example-decoded-payload).
143
+
The `namespace` option is used when all of the Hasura claims are present in a single object within the decoded JWT. Our
144
+
example uses `claims.jwt.hasura.io` in the [Example Decoded Payload](#example-decoded-payload).
144
145
145
146
```yaml
146
147
claimsConfig:
@@ -149,9 +150,11 @@ claimsConfig:
149
150
location: /claims.jwt.hasura.io
150
151
```
151
152
152
-
The `location` field indicates the location of the namespace object that uses [RFC 6901 JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) string syntax.
153
+
The `location` field indicates the location of the namespace object that uses
The `claimsFormat` field indicates whether the Hasura-specific claims are a regular JSON object or a stringified JSON. The following possible values are allowed: `Json`, `StringifiedJson`.
156
+
The `claimsFormat` field indicates whether the Hasura-specific claims are a regular JSON object or a stringified JSON.
157
+
The following possible values are allowed: `Json`, `StringifiedJson`.
155
158
156
159
This is required because providers like AWS Cognito only allow strings in the JWT claims.
@@ -190,12 +193,13 @@ If `claimsFormat` is `StringifiedJson` then the JWT claims should look like:
190
193
191
194
#### locations {#jwt-claims-config-locations}
192
195
193
-
This `locations` option can be used when Hasura claims are not all present in the single object, but individual claims are provided a JSON pointer within the decoded JWT.
194
-
In this option, you can indicate:
195
-
- a literal value.
196
+
This `locations` option can be used when Hasura claims are not all present in the single object, but individual claims
197
+
are provided a JSON pointer within the decoded JWT. In this option, you can indicate:
198
+
199
+
- a literal value.
196
200
- or a JSON pointer path for individual claims and an optional default value if the claim doesn't exist.
197
201
198
-
`x-hasura-default-role`and `x-hasura-allowed-roles` claims are required. Other custom claims are optionally configured.
202
+
`x-hasura-default-role`and `x-hasura-allowed-roles` claims are required. Other custom claims are optionally configured.
199
203
200
204
The literal values should be of type `String`, except for the `x-hasura-allowed-roles` claim which expects a string
201
205
array.
@@ -221,12 +225,12 @@ The mapping for `x-hasura-allowed-roles`, `x-hasura-default-role` and `x-hasura-
221
225
specified in the `locations` configuration as follows:
222
226
223
227
```yaml
224
-
claimsConfig:
228
+
claimsConfig:
225
229
locations:
226
-
x-hasura-default-role:
230
+
x-hasura-default-role:
227
231
path:
228
232
path: /hasura/all_roles/0
229
-
x-hasura-allowed-roles:
233
+
x-hasura-allowed-roles:
230
234
path:
231
235
path: /hasura/all_roles
232
236
x-hasura-user-id:
@@ -249,12 +253,12 @@ claimsConfig:
249
253
```
250
254
251
255
```yaml
252
-
claimsConfig:
256
+
claimsConfig:
253
257
locations:
254
-
x-hasura-default-role:
258
+
x-hasura-default-role:
255
259
path:
256
260
path: /hasura/all_roles/0
257
-
x-hasura-allowed-roles:
261
+
x-hasura-allowed-roles:
258
262
path:
259
263
path: /hasura/all_roles
260
264
x-hasura-user-id:
@@ -283,11 +287,11 @@ In the above case, since the `/user/id` doesn't exist in the JWT token, the defa
283
287
The corresponding JWT config should be:
284
288
285
289
```yaml
286
-
claimsConfig:
290
+
claimsConfig:
287
291
locations:
288
-
x-hasura-default-role:
292
+
x-hasura-default-role:
289
293
literal: user
290
-
x-hasura-allowed-roles:
294
+
x-hasura-allowed-roles:
291
295
literal: ["user", "editor"]
292
296
x-hasura-user-id:
293
297
path:
@@ -299,7 +303,7 @@ value of the `x-hasura-user-id` is a JSON path to the value in the JWT token.
299
303
300
304
### tokenLocation
301
305
302
-
Indicates the token location where request header to read the JWT from.
306
+
Indicates the token location where request header to read the JWT from.
303
307
304
308
The following are the possible values:
305
309
@@ -308,7 +312,7 @@ The following are the possible values:
308
312
In this mode, Hasura expects an `Authorization` header with a `Bearer` token.
309
313
310
314
```yaml
311
-
tokenLocation:
315
+
tokenLocation:
312
316
type: BearerAuthorization
313
317
```
314
318
@@ -324,7 +328,7 @@ In the cookie mode, Hasura will try to parse the cookie header with the given co
value: '-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdlatRjRjogo3WojgGHFHYLugd\nUWAY9iR3fy4arWNA1KoS8kVw33cJibXr8bvwUAUparCwlvdbH6dvEOfou0/gCFQs\nHUfQrSDv+MuSUMAe8jzKE4qW+jK+xQU9a03GUnKHkkle+Q0pX/g6jXZ7r1/xAK5D\no2kQ+X5xK9cipRgEKwIDAQAB\n-----END PUBLIC KEY-----\n'
value: '-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEVs/o5+uQbTjL3chynL4wXgUg2R9\nq9UU8I5mEovUf86QZ7kOBIjJwqnzD1omageEHWwHdBO6B+dFabmdT9POxg==\n-----END PUBLIC KEY-----'
0 commit comments