From 49eaf0feea21ae19156d90be9fafc3f6f425e5f7 Mon Sep 17 00:00:00 2001 From: Stephen Stack Date: Sun, 12 Feb 2017 16:41:11 -0600 Subject: [PATCH 1/3] deps: require django-allauth>=0.25.0 --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 32ea6b7..806ee33 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ setup( 'Django>=1.8.0', 'djangorestframework>=3.1.0', 'six>=1.9.0', + 'django-allauth>=0.25.0', ], extras_require={ 'with_social': ['django-allauth>=0.25.0'], From 9cf4c4e730c8f9281949b1ee9b78cbb0b747fd32 Mon Sep 17 00:00:00 2001 From: Stephen Stack Date: Sun, 12 Feb 2017 16:47:03 -0600 Subject: [PATCH 2/3] deps: dev-requirements.txt to install developer dependencies --- dev-requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 dev-requirements.txt diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..b0a8d61 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,3 @@ +--editable . +responses>=0.5.0 +djangorestframework-jwt From be17865b0040b70fa9400abffeb11139503aaa91 Mon Sep 17 00:00:00 2001 From: Stephen Stack Date: Sun, 12 Feb 2017 17:35:28 -0600 Subject: [PATCH 3/3] registration: allow custom permission classes --- rest_auth/registration/app_settings.py | 8 ++++++++ rest_auth/registration/views.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rest_auth/registration/app_settings.py b/rest_auth/registration/app_settings.py index 227b45b..68c3a78 100644 --- a/rest_auth/registration/app_settings.py +++ b/rest_auth/registration/app_settings.py @@ -1,5 +1,6 @@ from django.conf import settings +from rest_framework.permissions import AllowAny from rest_auth.registration.serializers import ( RegisterSerializer as DefaultRegisterSerializer) from ..utils import import_callable @@ -9,3 +10,10 @@ serializers = getattr(settings, 'REST_AUTH_REGISTER_SERIALIZERS', {}) RegisterSerializer = import_callable( serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer)) + + +def register_permission_classes(): + permission_classes = [AllowAny, ] + for klass in getattr(settings, 'REST_AUTH_REGISTER_PERMISSION_CLASSES', tuple()): + permission_classes.append(import_callable(klass)) + return tuple(permission_classes) diff --git a/rest_auth/registration/views.py b/rest_auth/registration/views.py index e35153d..d6638b6 100644 --- a/rest_auth/registration/views.py +++ b/rest_auth/registration/views.py @@ -22,7 +22,7 @@ from rest_auth.registration.serializers import (SocialLoginSerializer, VerifyEmailSerializer) from rest_auth.utils import jwt_encode from rest_auth.views import LoginView -from .app_settings import RegisterSerializer +from .app_settings import RegisterSerializer, register_permission_classes sensitive_post_parameters_m = method_decorator( sensitive_post_parameters('password1', 'password2') @@ -31,7 +31,7 @@ sensitive_post_parameters_m = method_decorator( class RegisterView(CreateAPIView): serializer_class = RegisterSerializer - permission_classes = (AllowAny, ) + permission_classes = register_permission_classes() token_model = TokenModel @sensitive_post_parameters_m