A custom user model for django authentication
Project description
Django custom user model
A Custom User model for authentication
Requirement
- Python (3.5, 3.6, 3.7, 3.8)
- Django (1.11, >2.0, 2.1, 2.2, 3.0, 3.1)
Installation
Install using pip
pip install django-custom-user-models
Add to INSTALLED_APPS
setting
INSTALLED_APPS = {
...
'CustomAuth',
...
}
Set AUTH_USER_MODEL
setting before first migrate
AUTH_USER_MODEL = 'CustomAuth.User'
Migrate apps
py manage.py migrate
Usage
Status Handler
Add handler
to yourproject/urls.py
from CustomAuth.urls import handler400, handler401, handler403, handler404, handler500
Authentication template
Add to settings.py
profile url
USER_PROFILE_URL = '<your user profile url>' # default '/profile/'
login redirect url
LOGIN_REDIRECT_URL = '<your login redirect>' # default '/account/profile/'
logout redirect url
LOGOUT_REDIRECT = '<your logout redirect>' # default '/'
signup successfully redirect
SIGNUP_SUCCESSFULLY_URL = '<your signup successfully redirect url>' # default '/profile/'
verification successfully redirect
VERIFY_SUCCESSFULLY = '<your verify successfully redirect url>' # default '/profile/'
verification failed redirect
VERIFY_FAILED = '<your verify failed redirect url>' # default 'Verification link is invalid!'
Email config
For verify email you should config email smtp server, example(gmail):
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'your name@gmail.com'
EMAIL_HOST_PASSWORD = 'your password'
EMAIL_USE_TSL = True
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
EMAIL_FROM = EMAIL_HOST_USER
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
Magic Link
Use magic link for auto authentication user.
Add to settings.py
AUTHENTICATION_BACKENDS = (
# ...
'CustomAuth.backends.MagicLinkBackend', # magic backend
# ...
)
MIDDLEWARE = [
# ...
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
# ...
'CustomAuth.middleware.magic.MagicMiddleware', # Magic middleware
# ...
]
JWT Authentication
For get new jwt token with 2 month expire time.
curl -H "jwt-authentication:<your token>" -X GET <your host>/jwt/token
For authenticate with jwt use your token.
curl -H "jwt-authentication:<your token>" -X GET <your host>/<relative path>
Versioning
This project follows Semantic Versioning 2.0.0.
License
This project follows the BSD license. See the LICENSE for details.
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
Close
Hashes for django-custom-user-models-0.0.71.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2adac58ffabe99230bdc41f023da691c066c0339fe65b972f6f2ad6b81d5d992 |
|
MD5 | ec005b45f90954a6592253c5578d5d54 |
|
BLAKE2b-256 | 9d2632a5d3af842447d70d9a9b06d360e9d646bf68d494867eca3141b4e8a725 |
Close
Hashes for django_custom_user_models-0.0.71-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 251fe4dd9b1452a77b9743cac4db1ad2a236418b78eaba41dd14bf8b8be6f377 |
|
MD5 | 22d85ad825deb72efa538baca4025c38 |
|
BLAKE2b-256 | 901d365170f5036fad49384ed8c850161212a88c47881e997ba3ed05a2931b8f |