Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/advanced_topics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Write something like this in your settings module::

OAUTH2_PROVIDER_APPLICATION_MODEL='your_app_name.MyApplication'

Be aware that, when you intend to swap the application model, you should create and run the
migration defining the swapped application model prior to setting OAUTH2_PROVIDER_APPLICATION_MODEL.
You'll run into models.E022 in Core system checks if you don't get the order right.

That's all, now Django OAuth Toolkit will use your model wherever an Application instance is needed.

**Notice:** `OAUTH2_PROVIDER_APPLICATION_MODEL` is the only setting variable that is not namespaced, this
Expand Down
12 changes: 11 additions & 1 deletion oauth2_provider/middleware.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
from django.contrib.auth import authenticate
from django.utils.cache import patch_vary_headers

# bastb Django 1.10 has updated Middleware. This code imports the Mixin required to get old-style
# middleware working again
# More?
# https://docs.djangoproject.com/en/1.10/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware
try:
from django.utils.deprecation import MiddlewareMixin
middleware_parent_class = MiddlewareMixin
except ImportError:
middleware_parent_class = object

class OAuth2TokenMiddleware(object):

class OAuth2TokenMiddleware(middleware_parent_class):
"""
Middleware for OAuth2 user authentication

Expand Down