Skip to content

Commit 911f7b8

Browse files
bastbnlsynasius
authored andcommitted
Should fix #406
Should now work with old-style Middleware and the Django 1.10 new style
1 parent 34a5263 commit 911f7b8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

oauth2_provider/middleware.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
from django.contrib.auth import authenticate
22
from django.utils.cache import patch_vary_headers
33

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

5-
class OAuth2TokenMiddleware(object):
14+
15+
class OAuth2TokenMiddleware(middleware_parent_class):
616
"""
717
Middleware for OAuth2 user authentication
818

0 commit comments

Comments
 (0)