Commit bd8569ee authored by Michael Fladischer's avatar Michael Fladischer

Import djoser_0.4.2.orig.tar.gz

parent 75bce4e1
Metadata-Version: 1.1
Name: djoser
Version: 0.4.0
Version: 0.4.2
Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS
......@@ -41,8 +41,8 @@ Description: djoser
- ``/me/``
- ``/register/``
- ``/login/``
- ``/logout/``
- ``/login/`` (token based authentication)
- ``/logout/`` (token based authentication)
- ``/activate/``
- ``/{{ User.USERNAME_FIELD }}/``
- ``/password/``
......@@ -54,6 +54,7 @@ Description: djoser
- Python 2.6
- Python 2.7
- Python 3.4
- Python 3.5
Supported Django versions:
......@@ -61,6 +62,7 @@ Description: djoser
- Django 1.6
- Django 1.7
- Django 1.8
- Django 1.9
Supported Django Rest Framework versions:
......@@ -180,6 +182,7 @@ Description: djoser
'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
'ACTIVATION_URL': '#/activate/{uid}/{token}',
'SEND_ACTIVATION_EMAIL': True,
'PASSWORD_VALIDATORS': []
}
Check "Settings" section for more info.
......@@ -280,6 +283,8 @@ Description: djoser
Use this endpoint to obtain user `authentication
token <http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication>`__.
This endpoint is available only if you are using token based
authentication.
``POST``
^^^^^^^^
......@@ -306,6 +311,8 @@ Description: djoser
~~~~~~
Use this endpoint to logout user (remove user authentication token).
This endpoint is available only if you are using token based
authentication.
``POST``
^^^^^^^^
......@@ -512,6 +519,18 @@ Description: djoser
**Default**: ``False``
PASSWORD\_VALIDATORS
~~~~~~~~~~~~~~~~~~~~
List containing `REST Framework
Validator <http://www.django-rest-framework.org/api-guide/validators/>`__
functions. These validators are run on ``/register/`` and
``/password/reset/confirm/``.
**Default**: ``[]``
**Example**: ``[my_validator1, my_validator2]``
Emails
------
......@@ -661,6 +680,13 @@ Description: djoser
``$ ./manage.py test``
If you need to run tests against all supported Python and Django
versions then invoke:
``$ pip install tox``
``$ tox``
Similar projects
----------------
......
......@@ -25,8 +25,8 @@ Available endpoints:
* `/me/`
* `/register/`
* `/login/`
* `/logout/`
* `/login/` (token based authentication)
* `/logout/` (token based authentication)
* `/activate/`
* `/{{ User.USERNAME_FIELD }}/`
* `/password/`
......@@ -38,6 +38,7 @@ Supported Python versions:
* Python 2.6
* Python 2.7
* Python 3.4
* Python 3.5
Supported Django versions:
......@@ -45,12 +46,13 @@ Supported Django versions:
* Django 1.6
* Django 1.7
* Django 1.8
* Django 1.9
Supported Django Rest Framework versions:
* Django Rest Framework 3.x
For Django Rest Framework 2.4 support check [djoser 0.3.2](https://github.com/sunscrapers/djoser/tree/0.3.2).
For Django Rest Framework 2.4 support check [djoser 0.3.2](https://github.com/sunscrapers/djoser/tree/0.3.2).
## Installation
......@@ -147,6 +149,7 @@ DJOSER = {
'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
'ACTIVATION_URL': '#/activate/{uid}/{token}',
'SEND_ACTIVATION_EMAIL': True,
'PASSWORD_VALIDATORS': []
}
```
......@@ -237,6 +240,7 @@ URL: `/register/`
### Login
Use this endpoint to obtain user [authentication token](http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication).
This endpoint is available only if you are using token based authentication.
#### `POST`
......@@ -260,7 +264,8 @@ URL: `/login/`
### Logout
Use this endpoint to logout user (remove user authentication token).
Use this endpoint to logout user (remove user authentication token). This endpoint is available only if you are using
token based authentication.
#### `POST`
......@@ -442,6 +447,15 @@ endpoint in order to validate password equality.
**Default**: `False`
### PASSWORD_VALIDATORS
List containing [REST Framework Validator](http://www.django-rest-framework.org/api-guide/validators/) functions.
These validators are run on `/register/` and `/password/reset/confirm/`.
**Default**: `[]`
**Example**: `[my_validator1, my_validator2]`
## Emails
There are few email templates which you may want to override:
......@@ -577,6 +591,12 @@ In order to run the tests create virtualenv, go to repo directory and then:
`$ ./manage.py test`
If you need to run tests against all supported Python and Django versions then invoke:
`$ pip install tox`
`$ tox`
## Similar projects
List of projects related to Django, REST and authentication:
......
Metadata-Version: 1.1
Name: djoser
Version: 0.4.0
Version: 0.4.2
Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS
......@@ -41,8 +41,8 @@ Description: djoser
- ``/me/``
- ``/register/``
- ``/login/``
- ``/logout/``
- ``/login/`` (token based authentication)
- ``/logout/`` (token based authentication)
- ``/activate/``
- ``/{{ User.USERNAME_FIELD }}/``
- ``/password/``
......@@ -54,6 +54,7 @@ Description: djoser
- Python 2.6
- Python 2.7
- Python 3.4
- Python 3.5
Supported Django versions:
......@@ -61,6 +62,7 @@ Description: djoser
- Django 1.6
- Django 1.7
- Django 1.8
- Django 1.9
Supported Django Rest Framework versions:
......@@ -180,6 +182,7 @@ Description: djoser
'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
'ACTIVATION_URL': '#/activate/{uid}/{token}',
'SEND_ACTIVATION_EMAIL': True,
'PASSWORD_VALIDATORS': []
}
Check "Settings" section for more info.
......@@ -280,6 +283,8 @@ Description: djoser
Use this endpoint to obtain user `authentication
token <http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication>`__.
This endpoint is available only if you are using token based
authentication.
``POST``
^^^^^^^^
......@@ -306,6 +311,8 @@ Description: djoser
~~~~~~
Use this endpoint to logout user (remove user authentication token).
This endpoint is available only if you are using token based
authentication.
``POST``
^^^^^^^^
......@@ -512,6 +519,18 @@ Description: djoser
**Default**: ``False``
PASSWORD\_VALIDATORS
~~~~~~~~~~~~~~~~~~~~
List containing `REST Framework
Validator <http://www.django-rest-framework.org/api-guide/validators/>`__
functions. These validators are run on ``/register/`` and
``/password/reset/confirm/``.
**Default**: ``[]``
**Example**: ``[my_validator1, my_validator2]``
Emails
------
......@@ -661,6 +680,13 @@ Description: djoser
``$ ./manage.py test``
If you need to run tests against all supported Python and Django
versions then invoke:
``$ pip install tox``
``$ tox``
Similar projects
----------------
......
......@@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _
INVALID_CREDENTIALS_ERROR = _('Unable to login with provided credentials.')
INACTIVE_ACCOUNT_ERROR = _('User account is disabled.')
INVALID_TOKEN_ERROR = _('Invalid token for given user.')
STALE_TOKEN_ERROR = _('Stale token for given user.')
PASSWORD_MISMATCH_ERROR = _('The two password fields didn\'t match.')
USERNAME_MISMATCH_ERROR = _('The two {0} fields didn\'t match.')
INVALID_PASSWORD_ERROR = _('Invalid password.')
from django.contrib.auth import authenticate, get_user_model
from rest_framework import serializers
from rest_framework import exceptions, serializers
from rest_framework.authtoken.models import Token
from . import constants, utils
from . import constants, utils, settings
User = get_user_model()
......@@ -20,7 +20,9 @@ class UserSerializer(serializers.ModelSerializer):
class UserRegistrationSerializer(serializers.ModelSerializer):
password = serializers.CharField(style={'input_type': 'password'}, write_only=True)
password = serializers.CharField(style={'input_type': 'password'},
write_only=True,
validators=settings.get('PASSWORD_VALIDATORS'))
class Meta:
model = User
......@@ -66,7 +68,7 @@ class UidAndTokenSerializer(serializers.Serializer):
token = serializers.CharField()
default_error_messages = {
'invalid_token': constants.INVALID_TOKEN_ERROR
'invalid_token': constants.INVALID_TOKEN_ERROR,
}
def validate_uid(self, value):
......@@ -74,7 +76,7 @@ class UidAndTokenSerializer(serializers.Serializer):
uid = utils.decode_uid(value)
self.user = User.objects.get(pk=uid)
except (User.DoesNotExist, ValueError, TypeError, OverflowError) as error:
raise serializers.ValidationError(error)
raise serializers.ValidationError(str(error))
return value
def validate(self, attrs):
......@@ -84,8 +86,21 @@ class UidAndTokenSerializer(serializers.Serializer):
return attrs
class ActivationSerializer(UidAndTokenSerializer):
default_error_messages = {
'stale_token': constants.STALE_TOKEN_ERROR,
}
def validate(self, attrs):
attrs = super(ActivationSerializer, self).validate(attrs)
if self.user.is_active:
raise exceptions.PermissionDenied(self.error_messages['stale_token'])
return attrs
class PasswordSerializer(serializers.Serializer):
new_password = serializers.CharField(style={'input_type': 'password'})
new_password = serializers.CharField(style={'input_type': 'password'},
validators=settings.get('PASSWORD_VALIDATORS'))
class PasswordRetypeSerializer(PasswordSerializer):
......
......@@ -9,9 +9,10 @@ def get(key):
'SET_USERNAME_RETYPE': False,
'PASSWORD_RESET_CONFIRM_RETYPE': False,
'ROOT_VIEW_URLS_MAPPING': {},
'PASSWORD_VALIDATORS': []
}
defaults.update(getattr(settings, 'DJOSER', {}))
try:
return defaults[key]
except KeyError:
raise ImproperlyConfigured('Missing settings: DJOSER[\'{}\']'.format(key))
\ No newline at end of file
raise ImproperlyConfigured('Missing settings: DJOSER[\'{}\']'.format(key))
from django.conf.urls import patterns, url
from django.conf.urls import url
from djoser import views
from . import base
urlpatterns = base.base_urlpatterns + patterns('',
urlpatterns = base.base_urlpatterns + (
url(r'^login/$', views.LoginView.as_view(), name='login'),
url(r'^logout/$', views.LogoutView.as_view(), name='logout'),
url(r'^$', views.RootView.as_view(urls_extra_mapping={'login': 'login', 'logout': 'logout'}), name='root'),
......
from django.conf.urls import patterns, url
from django.conf.urls import url
from djoser import views
from django.contrib.auth import get_user_model
User = get_user_model()
base_urlpatterns = patterns('',
base_urlpatterns = (
url(r'^me/$', views.UserView.as_view(), name='user'),
url(r'^register/$', views.RegistrationView.as_view(), name='register'),
url(r'^activate/$', views.ActivationView.as_view(), name='activate'),
......@@ -14,4 +14,4 @@ base_urlpatterns = patterns('',
url(r'^password/reset/confirm/$', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
)
urlpatterns = base_urlpatterns + patterns('', url(r'^$', views.RootView.as_view(), name='root'))
urlpatterns = base_urlpatterns + (url(r'^$', views.RootView.as_view(), name='root'),)
......@@ -97,12 +97,8 @@ class SendEmailViewMixin(object):
def get_email_context(self, user):
token = self.token_generator.make_token(user)
uid = encode_uid(user.pk)
try:
domain = django_settings.DJOSER['DOMAIN']
site_name = django_settings.DJOSER['SITE_NAME']
except KeyError:
site = get_current_site(self.request)
domain, site_name = site.domain, site.name
domain = django_settings.DJOSER.get('DOMAIN') or get_current_site(self.request).domain
site_name = django_settings.DJOSER.get('SITE_NAME') or get_current_site(self.request).name
return {
'user': user,
'domain': domain,
......
......@@ -172,7 +172,7 @@ class ActivationView(utils.ActionViewMixin, generics.GenericAPIView):
"""
Use this endpoint to activate user account.
"""
serializer_class = serializers.UidAndTokenSerializer
serializer_class = serializers.ActivationSerializer
permission_classes = (
permissions.AllowAny,
)
......
[egg_info]
tag_build =
tag_svn_revision = 0
tag_date = 0
tag_build =
......@@ -22,7 +22,7 @@ def get_requirements(file_name):
setup(
name='djoser',
version='0.4.0',
version='0.4.2',
packages=get_packages('djoser'),
license='MIT',
author='SUNSCRAPERS',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment