Skip to content

Commit 10c758d

Browse files
author
Landon Gilbert-Bland
committed
Finish updates for configuration option documentation
1 parent 5bf88e6 commit 10c758d

File tree

1 file changed

+115
-44
lines changed

1 file changed

+115
-44
lines changed

docs/options.rst

Lines changed: 115 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -254,58 +254,129 @@ Cross Site Request Forgery Options
254254
These are only applicable if a route is configured to accept JWTs via cookies and
255255
``JWT_COOKIE_CSRF_PROTECT`` is ``True``.
256256

257-
.. tabularcolumns:: |p{6.5cm}|p{8.5cm}|
258-
259-
================================= =========================================
260-
``JWT_CSRF_METHODS`` The request types that will use CSRF protection. Defaults to
261-
``['POST', 'PUT', 'PATCH', 'DELETE']``
262-
``JWT_ACCESS_CSRF_HEADER_NAME`` Name of the header that should contain the CSRF double submit value
263-
for access tokens. Defaults to ``X-CSRF-TOKEN``.
264-
``JWT_REFRESH_CSRF_HEADER_NAME`` Name of the header that should contains the CSRF double submit value
265-
for refresh tokens. Defaults to ``X-CSRF-TOKEN``.
266-
``JWT_CSRF_IN_COOKIES`` If we should store the CSRF double submit value in
267-
another cookies when using ``set_access_cookies()`` and
268-
``set_refresh_cookies()``. Defaults to ``True``. If this is
269-
False, you are responsible for getting the CSRF value to the
270-
callers (see: ``get_csrf_token(encoded_token)``).
271-
``JWT_ACCESS_CSRF_COOKIE_NAME`` Name of the CSRF access cookie. Defaults to ``'csrf_access_token'``.
272-
Only applicable if ``JWT_CSRF_IN_COOKIES`` is ``True``
273-
``JWT_REFRESH_CSRF_COOKIE_NAME`` Name of the CSRF refresh cookie. Defaults to ``'csrf_refresh_token'``.
274-
Only applicable if ``JWT_CSRF_IN_COOKIES`` is ``True``
275-
``JWT_ACCESS_CSRF_COOKIE_PATH`` Path for the CSRF access cookie. Defaults to ``'/'``.
276-
Only applicable if ``JWT_CSRF_IN_COOKIES`` is ``True``
277-
``JWT_REFRESH_CSRF_COOKIE_PATH`` Path of the CSRF refresh cookie. Defaults to ``'/'``.
278-
Only applicable if ``JWT_CSRF_IN_COOKIES`` is ``True``
279-
``JWT_CSRF_CHECK_FORM`` When no CSRF token can be found in the header, check the form data. Defaults to
280-
``False``.
281-
``JWT_ACCESS_CSRF_FIELD_NAME`` Name of the form field that should contain the CSRF double submit value for access
282-
tokens when no header is present. Only applicable if ``JWT_CSRF_CHECK_FORM`` is
283-
``True``. Defaults to ``'csrf_token'``.
284-
``JWT_REFRESH_CSRF_FIELD_NAME`` Name of the form field that should contain the CSRF double submit value for refresh
285-
tokens when no header is present. Only applicable if ``JWT_CSRF_CHECK_FORM`` is
286-
``True``. Defaults to ``'csrf_token'``.
287-
================================= =========================================
257+
258+
.. py:data:: JWT_CSRF_METHODS
259+
260+
A list of HTTP methods that we should do CSRF checks on.
261+
262+
Default: ``["POST", "PUT", "PATCH", "DELETE"]``
263+
264+
265+
.. py:data:: JWT_ACCESS_CSRF_HEADER_NAME
266+
267+
The name of the header on an incoming request that should contain the CSRF
268+
double submit token.
269+
270+
Default: ``"X-CSRF-TOKEN"``
271+
272+
273+
.. py:data:: JWT_REFRESH_CSRF_HEADER_NAME
274+
275+
The name of the header on an incoming request that should contain the CSRF
276+
double submit token.
277+
278+
Note: We generally do not recommend using refresh tokens with cookies. See
279+
:ref:`Implicit Refreshing With Cookies`.
280+
281+
Default: ``"X-CSRF-TOKEN"``
282+
283+
284+
.. py:data:: JWT_CSRF_IN_COOKIES
285+
286+
Controls if the CSRF double submit token will be stored in additional cookies.
287+
If setting this to ``False``, you can use :func:`flask_jwt_extended.get_csrf_token`
288+
to get the csrf token from an encoded JWT, and return it to your frontend in
289+
whatever way suites your application.
290+
291+
Default: ``True``
292+
293+
294+
.. py:data:: JWT_ACCESS_CSRF_COOKIE_NAME
295+
296+
The name of the cookie that contains the CSRF double submit token. Only
297+
applicable if ``JWT_CSRF_IN_COOKIES`` is ``True``
298+
299+
Default: ``csrf_access_token``
300+
301+
302+
.. py:data:: JWT_REFRESH_CSRF_COOKIE_NAME
303+
304+
The name of the cookie that contains the CSRF double submit token. Only
305+
applicable if ``JWT_CSRF_IN_COOKIES`` is ``True``
306+
307+
Note: We generally do not recommend using refresh tokens with cookies. See
308+
:ref:`Implicit Refreshing With Cookies`.
309+
310+
Default: ``csrf_refresh_token``
311+
312+
313+
.. py:data:: JWT_ACCESS_CSRF_COOKIE_PATH
314+
315+
The path of the access CSRF double submit cookie.
316+
317+
Default: ``"/"``
318+
319+
320+
.. py:data:: JWT_REFRESH_CSRF_COOKIE_PATH
321+
322+
The path of the refresh CSRF double submit cookie.
323+
324+
Note: We generally do not recommend using refresh tokens with cookies. See
325+
:ref:`Implicit Refreshing With Cookies`.
326+
327+
Default: ``"/"``
328+
329+
330+
.. py:data:: JWT_CSRF_CHECK_FORM
331+
332+
Controls if form data should also be check for the CSRF double submit token.
333+
334+
Default: ``False``
335+
336+
337+
.. py:data:: JWT_ACCESS_CSRF_FIELD_NAME
338+
339+
Name of the form field that should contain the CSRF double submit token for
340+
an access token. Only applicable if ``JWT_CSRF_CHECK_FORM`` is ``True``
341+
342+
Default: ``"csrf_token"``
343+
344+
345+
.. py:data:: JWT_REFRESH_CSRF_FIELD_NAME
346+
347+
Name of the form field that should contain the CSRF double submit token for
348+
a refresh token. Only applicable if ``JWT_CSRF_CHECK_FORM`` is ``True``
349+
350+
Note: We generally do not recommend using refresh tokens with cookies. See
351+
:ref:`Implicit Refreshing With Cookies`.
352+
353+
Default: ``"csrf_token"``
288354

289355

290356
Query String Options:
291357
~~~~~~~~~~~~~~~~~~~~~
292-
These are only applicable if ``JWT_TOKEN_LOCATION`` is set to use query strings.
358+
These are only applicable if a route is configured to accept JWTs via query string.
293359

294-
.. tabularcolumns:: |p{6.5cm}|p{8.5cm}|
360+
.. py:data:: JWT_QUERY_STRING_NAME
295361
296-
================================= =========================================
297-
``JWT_QUERY_STRING_NAME`` What query paramater name to look for a JWT in a request. Defaults to ``'jwt'``
298-
================================= =========================================
362+
What query string parameter should contain the JWT.
299363

364+
Default: ``"jwt"``
300365

301366

302-
Json Body Options:
303-
~~~~~~~~~~~~~~~~~~~~~
304-
These are only applicable if ``JWT_TOKEN_LOCATION`` is set to use json data.
367+
JSON Body Options:
368+
~~~~~~~~~~~~~~~~~~
369+
These are only applicable if a route is configured to accept JWTs via the JSON body.
370+
371+
.. py:data:: JWT_JSON_KEY
372+
373+
What key should contain the access token in the JSON body of a request.
374+
375+
Default: ``"access_token"``
376+
377+
378+
.. py:data:: JWT_REFRESH_JSON_KEY
305379
306-
.. tabularcolumns:: |p{6.5cm}|p{8.5cm}|
380+
What key should contain the refresh token in the JSON body of a request.
307381

308-
================================= =========================================
309-
``JWT_JSON_KEY`` Key to look for in the body of an `application/json` request. Defaults to ``'access_token'``
310-
``JWT_REFRESH_JSON_KEY`` Key to look for the refresh token in an `application/json` request. Defaults to ``'refresh_token'``
311-
================================= =========================================
382+
Default: ``"access_token"``

0 commit comments

Comments
 (0)