Skip to content

Commit fd127f4

Browse files
committed
docs: correct order of jwt claims sections
1 parent ad25479 commit fd127f4

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

docs/references/auth.rst

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,14 @@ It goes as follows:
168168

169169
- If the JWT does not have a ``kid`` parameter, then PostgREST will validate the token against each JWK in the :ref:`jwt-secret`.
170170

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-
187171
.. _jwt_claims_validation:
188172

189173
JWT Claims Validation
190174
---------------------
191175

176+
Time-Based claims validation
177+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178+
192179
The time-based JWT claims specified in `RFC 7519 <https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4>`_ are validated:
193180

194181
- ``exp`` Expiration Time
@@ -197,6 +184,22 @@ The time-based JWT claims specified in `RFC 7519 <https://datatracker.ietf.org/d
197184

198185
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.
199186

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.
202+
200203
.. _jwt_caching:
201204

202205
JWT Cache

docs/references/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ jwt-aud
603603
**In-Database** pgrst.jwt_aud
604604
=============== =================================
605605

606-
Specifies an audience for the JWT ``aud`` claim. See :ref:`jwt_aud_verification`.
606+
Specifies an audience for the JWT ``aud`` claim. See :ref:`jwt_aud`.
607607

608608
.. _jwt-role-claim-key:
609609

0 commit comments

Comments
 (0)