A custom user-model based package with features ranging from JWT and Basic authentication to REST API end-points for signup, signin, email verification, password resetting and account activation.
Project description
Welcome to django-rest-xauth
A custom user model based django-package to implement a secure and easily customizable JWT and Basic authentication in 5 simple steps for django project(s). It provides JSON formatted REST API end-points for signup, signin, email verification, password resetting and account activation.
Email verification and password resetting are based on hashed verification-code and temporary password respectively. Account activation is based on a combination of user selected security question(provided through the admin portal by site administrator(superuser)) and an answer.
What makes django-rest-xauth different
- Custom user class provides some common optional fields with reasonable complementary helper methods. For example,
date_of_birthfield that also comes with an age calculation helper method - Access logging(IP-address should be provided as a
X-Forwarded-Forheader) - Failed Sign-in attempts logging(IP-address should be provided as a
X-Forwarded-Forheader) - Password-reset logging(IP-address should be provided as a
X-Forwarded-Forheader) - Encrypted JWT tokens
- Security question based account activation in-case account was deactivated
- Temporary password based user password reset
- Verification code based user account activation.
N/B: temporary passwords and verification codes are both generated and returned from the
Usermodel hence opting to SMS based sending of the verification codes and temporary passwords should be as easy as extending theUsermodel, overriding a single method(that also generates and returns the code) and finally changing django'sAUTH_USER_MODELto your model name as explained here.
Quick start
- Install package
pip install django-rest-xauth
Modify your Django project's settings.py file
- Add xauth to your
INSTALLED_APPSsetting like this
INSTALLED_APPS = [
...,
'xauth',
'rest_framework',
]
- Add/modify your
AUTH_USER_MODELsetting to
# Can also be a (modified) direct subclass of `xauth.models.AbstractUser`
AUTH_USER_MODEL = 'xauth.User'
- Add/modify your
REST_FRAMEWORKsetting to
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'xauth.authentication.BasicTokenAuthentication',
...,
],
'EXCEPTION_HANDLER': 'xauth.utils.exceptions.exception_handler',
}
- Include the xauth URLconf in your project
urls.pylike this
urlpatterns = [
path('accounts/', include('xauth.urls', namespace='xauth')),
...,
]
- Run
python manage.py migrateto create the xauth models. - Run
python manage.py createsuperuserto create a superuser account. - Run
python manage.py runserverto start the development server. - Visit
http://127.0.0.1:8000/accounts/signup/to register a new account.
API endpoints
Read more here.
Documentation and support
Full documentation for the project is available here.
Contributing
Please be sure to review contributing guidelines to learn how to help the project.
Postman Team
Join postman team.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-rest-xauth-1.0.7.tar.gz.
File metadata
- Download URL: django-rest-xauth-1.0.7.tar.gz
- Upload date:
- Size: 40.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cc122bf30cd85ccabe6d94720bcfcc0173362bb8750184755e6226d9ebb589d
|
|
| MD5 |
62601000d530de8a52f2c4c385404248
|
|
| BLAKE2b-256 |
32656cb40ad3fba9c50c420ec5bb2136c5b9dcfc421aaff0c8ba0845e8dbceab
|
File details
Details for the file django_rest_xauth-1.0.7-py3-none-any.whl.
File metadata
- Download URL: django_rest_xauth-1.0.7-py3-none-any.whl
- Upload date:
- Size: 42.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
592e3dc2d94c1f4f435f9068b55bd72fc617ee3b00765f30b80e71ac9cf02258
|
|
| MD5 |
e07f84e81e3df82f87055bdc8c9848c3
|
|
| BLAKE2b-256 |
181e9ce6447ffbaab027ac850440131dc84071961c7553d6d85dedcc50e2c024
|