1
1
Settings
2
2
========
3
3
4
- Our configurations are all namespaced under the ``OAUTH2_PROVIDER `` settings with the exception of
5
- ``OAUTH2_PROVIDER_APPLICATION_MODEL ``, ``OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL ``, ``OAUTH2_PROVIDER_GRANT_MODEL ``,
6
- ``OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL ``: this is because of the way Django currently implements
7
- swappable models. See `issue #90 <https://github.com/jazzband/django-oauth-toolkit/issues/90 >`_ for details.
4
+ Our configurations are all namespaced under the ``OAUTH2_PROVIDER `` settings, with the exception
5
+ of the `List of non-namespaced settings `_.
8
6
9
7
For example:
10
8
@@ -24,32 +22,24 @@ For example:
24
22
A big *thank you * to the guys from Django REST Framework for inspiring this.
25
23
26
24
27
- List of available settings
28
- --------------------------
25
+ List of available settings within OAUTH2_PROVIDER
26
+ -------------------------------------------------
29
27
30
28
ACCESS_TOKEN_EXPIRE_SECONDS
31
29
~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
-
33
30
Default: ``36000 ``
34
31
35
32
The number of seconds an access token remains valid. Requesting a protected
36
33
resource after this duration will fail. Keep this value high enough so clients
37
34
can cache the token for a reasonable amount of time.
38
35
39
- ACCESS_TOKEN_MODEL
40
- ~~~~~~~~~~~~~~~~~~
41
- The import string of the class (model) representing your access tokens. Overwrite
42
- this value if you wrote your own implementation (subclass of
43
- ``oauth2_provider.models.AccessToken ``).
44
-
45
36
ACCESS_TOKEN_GENERATOR
46
37
~~~~~~~~~~~~~~~~~~~~~~
47
38
Import path of a callable used to generate access tokens.
48
39
``oauthlib.oauth2.rfc6749.tokens.random_token_generator `` is (normally) used if not provided.
49
40
50
41
ALLOWED_REDIRECT_URI_SCHEMES
51
42
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52
-
53
43
Default: ``["http", "https"] ``
54
44
55
45
A list of schemes that the ``redirect_uri `` field will be validated against.
@@ -65,7 +55,6 @@ a per-application basis.
65
55
66
56
ALLOW_URI_WILDCARDS
67
57
~~~~~~~~~~~~~~~~~~~
68
-
69
58
Default: ``False ``
70
59
71
60
SECURITY WARNING: Enabling this setting can introduce security vulnerabilities. Only enable
@@ -96,7 +85,6 @@ deployments for development previews and user acceptance testing.
96
85
97
86
ALLOWED_SCHEMES
98
87
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
-
100
88
Default: ``["https"] ``
101
89
102
90
A list of schemes that the ``allowed_origins `` field will be validated against.
@@ -105,13 +93,6 @@ Adding ``"http"`` to the list is considered to be safe only for local developmen
105
93
Note that `OAUTHLIB_INSECURE_TRANSPORT <https://oauthlib.readthedocs.io/en/latest/oauth2/security.html#envvar-OAUTHLIB_INSECURE_TRANSPORT >`_
106
94
environment variable should be also set to allow HTTP origins.
107
95
108
-
109
- APPLICATION_MODEL
110
- ~~~~~~~~~~~~~~~~~
111
- The import string of the class (model) representing your applications. Overwrite
112
- this value if you wrote your own implementation (subclass of
113
- ``oauth2_provider.models.Application ``).
114
-
115
96
AUTHORIZATION_CODE_EXPIRE_SECONDS
116
97
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
117
98
Default: ``60 ``
@@ -214,12 +195,6 @@ period the application, the app then has only a consumed refresh token and the
214
195
only recourse is to have the user re-authenticate. A suggested value, if this
215
196
is enabled, is 2 minutes.
216
197
217
- REFRESH_TOKEN_MODEL
218
- ~~~~~~~~~~~~~~~~~~~
219
- The import string of the class (model) representing your refresh tokens. Overwrite
220
- this value if you wrote your own implementation (subclass of
221
- ``oauth2_provider.models.RefreshToken ``).
222
-
223
198
REFRESH_TOKEN_REUSE_PROTECTION
224
199
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225
200
When this is set to ``True `` (default ``False ``), and ``ROTATE_REFRESH_TOKEN `` is used, the server will check
@@ -257,15 +232,15 @@ Defaults to ``oauth2_provider.scopes.SettingsScopes``, which reads scopes throug
257
232
258
233
SCOPES
259
234
~~~~~~
260
- .. note :: (0.12.0+) Only used if ``ACCESS_TOKEN_GENERATOR `` is set to the SettingsScopes default.
235
+ .. note :: (0.12.0+) Only used if ``SCOPES_BACKEND_CLASS `` is set to the SettingsScopes default.
261
236
262
237
A dictionary mapping each scope name to its human description.
263
238
264
239
.. _settings_default_scopes :
265
240
266
241
DEFAULT_SCOPES
267
242
~~~~~~~~~~~~~~
268
- .. note :: (0.12.0+) Only used if ``ACCESS_TOKEN_GENERATOR `` is set to the SettingsScopes default.
243
+ .. note :: (0.12.0+) Only used if ``SCOPES_BACKEND_CLASS `` is set to the SettingsScopes default.
269
244
270
245
A list of scopes that should be returned by default.
271
246
This is a subset of the keys of the ``SCOPES `` setting.
@@ -277,13 +252,13 @@ By default this is set to ``'__all__'`` meaning that the whole set of ``SCOPES``
277
252
278
253
READ_SCOPE
279
254
~~~~~~~~~~
280
- .. note :: (0.12.0+) Only used if ``ACCESS_TOKEN_GENERATOR `` is set to the SettingsScopes default.
255
+ .. note :: (0.12.0+) Only used if ``SCOPES_BACKEND_CLASS `` is set to the SettingsScopes default.
281
256
282
257
The name of the *read * scope.
283
258
284
259
WRITE_SCOPE
285
260
~~~~~~~~~~~
286
- .. note :: (0.12.0+) Only used if ``ACCESS_TOKEN_GENERATOR `` is set to the SettingsScopes default.
261
+ .. note :: (0.12.0+) Only used if ``SCOPES_BACKEND_CLASS `` is set to the SettingsScopes default.
287
262
288
263
The name of the *write * scope.
289
264
@@ -340,7 +315,6 @@ Default: ``False``
340
315
341
316
Whether or not :doc: `oidc ` support is enabled.
342
317
343
-
344
318
OIDC_RSA_PRIVATE_KEY
345
319
~~~~~~~~~~~~~~~~~~~~
346
320
Default: ``"" ``
@@ -470,11 +444,47 @@ Time of sleep in seconds used by ``cleartokens`` management command between batc
470
444
Set this to a non-zero value (e.g. ``0.1 ``) to add a pause between batch sizes to reduce system
471
445
load when clearing large batches of expired tokens.
472
446
447
+ List of non-namespaced settings
448
+ -------------------------------
449
+ .. note ::
450
+ These settings must be set as top-level Django settings (outside of ``OAUTH2_PROVIDER ``),
451
+ because of the way Django currently implements swappable models.
452
+ See `issue #90 <https://github.com/jazzband/django-oauth-toolkit/issues/90 >`_ for details.
453
+
454
+
455
+ OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL
456
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
457
+ The import string of the class (model) representing your access tokens.
458
+ Overwrite this value if you wrote your own implementation (subclass of
459
+ ``oauth2_provider.models.AccessToken ``).
460
+
461
+ OAUTH2_PROVIDER_APPLICATION_MODEL
462
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
463
+ The import string of the class (model) representing your applications.
464
+ Overwrite this value if you wrote your own implementation (subclass of
465
+ ``oauth2_provider.models.Application ``).
466
+
467
+ OAUTH2_PROVIDER_ID_TOKEN_MODEL
468
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
469
+ The import string of the class (model) representing your OpenID Connect ID Token.
470
+ Overwrite this value if you wrote your own implementation (subclass of
471
+ ``oauth2_provider.models.IDToken ``).
472
+
473
+ OAUTH2_PROVIDER_GRANT_MODEL
474
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
475
+ The import string of the class (model) representing your OAuth2 grants.
476
+ Overwrite this value if you wrote your own implementation (subclass of
477
+ ``oauth2_provider.models.Grant ``).
478
+
479
+ OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL
480
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
481
+ The import string of the class (model) representing your refresh tokens.
482
+ Overwrite this value if you wrote your own implementation (subclass of
483
+ ``oauth2_provider.models.RefreshToken ``).
473
484
474
485
Settings imported from Django project
475
486
-------------------------------------
476
487
477
488
USE_TZ
478
489
~~~~~~
479
-
480
490
Used to determine whether or not to make token expire dates timezone aware.
0 commit comments