From a0277e9c4bc56ba36dd4a6073096cb1bee6112f3 Mon Sep 17 00:00:00 2001 From: Bas ten Berge Date: Tue, 9 Aug 2016 21:37:56 +0200 Subject: [PATCH 1/2] Should fix #406 Should now work with old-style Middleware and the Django 1.10 new style --- oauth2_provider/middleware.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/oauth2_provider/middleware.py b/oauth2_provider/middleware.py index 33eab12d5..0984443ca 100644 --- a/oauth2_provider/middleware.py +++ b/oauth2_provider/middleware.py @@ -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 From 5bfe4c7ef5d349eb8c7a6865fbb6bcc5f35790fd Mon Sep 17 00:00:00 2001 From: Bas ten Berge Date: Tue, 9 Aug 2016 21:45:03 +0200 Subject: [PATCH 2/2] Added notification concerning the migrations This should prevent others from running into #405 while trying to create both a swappable instance and swap it out at once --- docs/advanced_topics.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/advanced_topics.rst b/docs/advanced_topics.rst index dd0468f2f..6e1d5ace1 100644 --- a/docs/advanced_topics.rst +++ b/docs/advanced_topics.rst @@ -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