django-rest-auth/docs/configuration.rst

54 lines
2.8 KiB
ReStructuredText
Raw Normal View History

2014-10-09 15:01:47 +04:00
Configuration
=============
2014-10-09 16:53:39 +04:00
- **REST_AUTH_SERIALIZERS**
2014-10-09 15:01:47 +04:00
2014-10-09 16:53:39 +04:00
You can define your custom serializers for each endpoint without overriding urls and views by adding ``REST_AUTH_SERIALIZERS`` dictionary in your django settings.
Possible key values:
2014-10-09 15:01:47 +04:00
2015-08-07 13:54:45 +03:00
- LOGIN_SERIALIZER - serializer class in ``rest_auth.views.LoginView``, default value ``rest_auth.serializers.LoginSerializer``
2014-10-09 15:01:47 +04:00
2015-08-07 13:54:45 +03:00
- TOKEN_SERIALIZER - response for successful authentication in ``rest_auth.views.LoginView``, default value ``rest_auth.serializers.TokenSerializer``
2014-10-09 15:01:47 +04:00
- JWT_SERIALIZER - (Using REST_USE_JWT=True) response for successful authentication in ``rest_auth.views.LoginView``, default value ``rest_auth.serializers.JWTSerializer``
2015-08-07 13:54:45 +03:00
- USER_DETAILS_SERIALIZER - serializer class in ``rest_auth.views.UserDetailsView``, default value ``rest_auth.serializers.UserDetailsSerializer``
2014-10-09 15:01:47 +04:00
2015-08-07 13:54:45 +03:00
- PASSWORD_RESET_SERIALIZER - serializer class in ``rest_auth.views.PasswordResetView``, default value ``rest_auth.serializers.PasswordResetSerializer``
2014-10-09 15:01:47 +04:00
2015-08-07 13:54:45 +03:00
- PASSWORD_RESET_CONFIRM_SERIALIZER - serializer class in ``rest_auth.views.PasswordResetConfirmView``, default value ``rest_auth.serializers.PasswordResetConfirmSerializer``
2014-10-09 15:01:47 +04:00
2015-08-07 13:54:45 +03:00
- PASSWORD_CHANGE_SERIALIZER - serializer class in ``rest_auth.views.PasswordChangeView``, default value ``rest_auth.serializers.PasswordChangeSerializer``
2014-10-09 15:01:47 +04:00
2014-10-09 16:53:39 +04:00
Example configuration:
2014-10-09 15:01:47 +04:00
2014-10-09 16:53:39 +04:00
.. code-block:: python
2014-10-09 15:01:47 +04:00
2014-10-09 16:53:39 +04:00
REST_AUTH_SERIALIZERS = {
'LOGIN_SERIALIZER': 'path.to.custom.LoginSerializer',
'TOKEN_SERIALIZER': 'path.to.custom.TokenSerializer',
...
}
2016-02-25 23:37:08 +03:00
- **REST_AUTH_REGISTER_SERIALIZERS**
2015-11-24 13:11:46 +03:00
You can define your custom serializers for registration endpoint.
Possible key values:
2017-05-17 16:36:09 +03:00
- REGISTER_SERIALIZER - serializer class in ``rest_auth.registration.views.RegisterView``, default value ``rest_auth.registration.serializers.RegisterSerializer``
.. note:: The custom REGISTER_SERIALIZER must define a ``def save(self, request)`` method that returns a user model instance
2015-11-24 13:11:46 +03:00
2016-01-01 00:10:52 +03:00
- **REST_AUTH_TOKEN_MODEL** - model class for tokens, default value ``rest_framework.authtoken.models``
2014-10-09 16:53:39 +04:00
2016-01-01 00:10:52 +03:00
- **REST_AUTH_TOKEN_CREATOR** - callable to create tokens, default value ``rest_auth.utils.default_create_token``.
2014-11-12 14:18:12 +03:00
2016-01-01 00:10:52 +03:00
- **REST_SESSION_LOGIN** - Enable session login in Login API view (default: True)
2014-11-12 14:18:12 +03:00
2016-03-07 20:43:18 +03:00
- **REST_USE_JWT** - Enable JWT Authentication instead of Token/Session based. This is built on top of django-rest-framework-jwt http://getblimp.github.io/django-rest-framework-jwt/, which must also be installed. (default: False)
2014-11-12 14:18:12 +03:00
- **OLD_PASSWORD_FIELD_ENABLED** - set it to True if you want to have old password verification on password change enpoint (default: False)
- **LOGOUT_ON_PASSWORD_CHANGE** - set to False if you want to keep the current user logged in after a password change