11Settings
22========
33
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 `_.
86
97For example:
108
@@ -24,32 +22,24 @@ For example:
2422 A big *thank you * to the guys from Django REST Framework for inspiring this.
2523
2624
27- List of available settings
28- --------------------------
25+ List of available settings within OAUTH2_PROVIDER
26+ -------------------------------------------------
2927
3028ACCESS_TOKEN_EXPIRE_SECONDS
3129~~~~~~~~~~~~~~~~~~~~~~~~~~~
32-
3330Default: ``36000 ``
3431
3532The number of seconds an access token remains valid. Requesting a protected
3633resource after this duration will fail. Keep this value high enough so clients
3734can cache the token for a reasonable amount of time.
3835
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-
4536ACCESS_TOKEN_GENERATOR
4637~~~~~~~~~~~~~~~~~~~~~~
4738Import path of a callable used to generate access tokens.
4839``oauthlib.oauth2.rfc6749.tokens.random_token_generator `` is (normally) used if not provided.
4940
5041ALLOWED_REDIRECT_URI_SCHEMES
5142~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52-
5343Default: ``["http", "https"] ``
5444
5545A list of schemes that the ``redirect_uri `` field will be validated against.
@@ -65,7 +55,6 @@ a per-application basis.
6555
6656ALLOW_URI_WILDCARDS
6757~~~~~~~~~~~~~~~~~~~
68-
6958Default: ``False ``
7059
7160SECURITY WARNING: Enabling this setting can introduce security vulnerabilities. Only enable
@@ -96,7 +85,6 @@ deployments for development previews and user acceptance testing.
9685
9786ALLOWED_SCHEMES
9887~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99-
10088Default: ``["https"] ``
10189
10290A 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
10593Note that `OAUTHLIB_INSECURE_TRANSPORT <https://oauthlib.readthedocs.io/en/latest/oauth2/security.html#envvar-OAUTHLIB_INSECURE_TRANSPORT >`_
10694environment variable should be also set to allow HTTP origins.
10795
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-
11596AUTHORIZATION_CODE_EXPIRE_SECONDS
11697~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11798Default: ``60 ``
@@ -214,12 +195,6 @@ period the application, the app then has only a consumed refresh token and the
214195only recourse is to have the user re-authenticate. A suggested value, if this
215196is enabled, is 2 minutes.
216197
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-
223198REFRESH_TOKEN_REUSE_PROTECTION
224199~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225200When 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
257232
258233SCOPES
259234~~~~~~
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.
261236
262237A dictionary mapping each scope name to its human description.
263238
264239.. _settings_default_scopes :
265240
266241DEFAULT_SCOPES
267242~~~~~~~~~~~~~~
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.
269244
270245A list of scopes that should be returned by default.
271246This 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``
277252
278253 READ_SCOPE
279254~~~~~~~~~~
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.
281256
282257The name of the *read * scope.
283258
284259WRITE_SCOPE
285260~~~~~~~~~~~
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.
287262
288263The name of the *write * scope.
289264
@@ -340,7 +315,6 @@ Default: ``False``
340315
341316Whether or not :doc: `oidc ` support is enabled.
342317
343-
344318OIDC_RSA_PRIVATE_KEY
345319~~~~~~~~~~~~~~~~~~~~
346320Default: ``"" ``
@@ -470,11 +444,47 @@ Time of sleep in seconds used by ``cleartokens`` management command between batc
470444Set this to a non-zero value (e.g. ``0.1 ``) to add a pause between batch sizes to reduce system
471445load when clearing large batches of expired tokens.
472446
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 ``).
473484
474485Settings imported from Django project
475486-------------------------------------
476487
477488USE_TZ
478489~~~~~~
479-
480490Used to determine whether or not to make token expire dates timezone aware.
0 commit comments