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/references/auth.rst
+19-16Lines changed: 19 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -168,27 +168,14 @@ It goes as follows:
168
168
169
169
- If the JWT does not have a ``kid`` parameter, then PostgREST will validate the token against each JWK in the :ref:`jwt-secret`.
170
170
171
-
.. _jwt_aud_verification:
172
-
173
-
``aud`` verification
174
-
~~~~~~~~~~~~~~~~~~~~
175
-
176
-
PostgREST has built-in verification of the `JWT audience claim <https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3>`_.
177
-
It works this way:
178
-
179
-
- If :ref:`jwt-aud` is not set (the default), PostgREST identifies with all audiences and allows the JWT for any ``aud`` claim.
180
-
- If :ref:`jwt-aud` is set to a specific audience, PostgREST will check if this audience is present in the ``aud`` claim:
181
-
182
-
+ If the ``aud`` value is a JSON string, it will match it to the :ref:`jwt-aud`.
183
-
+ If the ``aud`` value is a JSON array of strings, it will search every element for a match.
184
-
+ If the match fails or if the ``aud`` value is not a string or array of strings, then the token will be rejected with a :ref:`401 Unauthorized <pgrst303>` error.
185
-
+ If the ``aud`` key **is not present** or if its value is ``null`` or ``[]``, PostgREST will interpret this token as allowed for all audiences and will complete the request.
186
-
187
171
.. _jwt_claims_validation:
188
172
189
173
JWT Claims Validation
190
174
---------------------
191
175
176
+
Time-Based claims validation
177
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178
+
192
179
The time-based JWT claims specified in `RFC 7519 <https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4>`_ are validated:
193
180
194
181
- ``exp`` Expiration Time
@@ -197,6 +184,22 @@ The time-based JWT claims specified in `RFC 7519 <https://datatracker.ietf.org/d
197
184
198
185
We allow a 30-second clock skew when validating the above claims. In other words, we give an extra 30 seconds before the JWT is rejected if there is a slight discrepancy in the timestamps.
199
186
187
+
.. _jwt_aud:
188
+
189
+
``aud`` validation
190
+
~~~~~~~~~~~~~~~~~~
191
+
192
+
PostgREST has built-in validation of the `JWT audience claim <https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3>`_.
193
+
It works this way:
194
+
195
+
- If :ref:`jwt-aud` is not set (the default), PostgREST identifies with all audiences and allows the JWT for any ``aud`` claim.
196
+
- If :ref:`jwt-aud` is set to a specific audience, PostgREST will check if this audience is present in the ``aud`` claim:
197
+
198
+
+ If the ``aud`` value is a JSON string, it will match it to the :ref:`jwt-aud`.
199
+
+ If the ``aud`` value is a JSON array of strings, it will search every element for a match.
200
+
+ If the match fails or if the ``aud`` value is not a string or array of strings, then the token will be rejected with a :ref:`401 Unauthorized <pgrst303>` error.
201
+
+ If the ``aud`` key **is not present** or if its value is ``null`` or ``[]``, PostgREST will interpret this token as allowed for all audiences and will complete the request.
0 commit comments