Django lightweight authentication without models and databases
Project description
django-light-auth
Django lightweight authentication without models and databases, only depend SessionMiddleware
Install
pip3 install -U django-light-auth
Basic Usage
settings.py
INSTALLED_APPS = [
# ...
'django_light_auth',
# ...
]
MIDDLEWARE = [
# ...
'django.contrib.sessions.middleware.SessionMiddleware',
# 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_light_auth.LightAuthMiddleware'
# ...
]
LIGHT_AUTH_VALIDATE_FUNC = 'your_app.auth.validate_func'
urls.py
from django.urls import path
from django_light_auth import LoginView, LogoutView
urlpatterns = [
# ...
path('login', LoginView.as_view(), name='login'),
path('logout', LogoutView.as_view(), name='logout'),
]
your_app/auth/validate_func.py
example at django_light_auth.light_auth_validate_func
from typing import Dict, Any
from your_app.config import config
def light_auth_validate_func(data: Dict[str, Any]) -> bool:
if data.get('username', None) == config.Auth.username and data.get(
'password', None
) == config.Auth.password:
return True
return False
Custom Login View
your_login_view.py
from django_light_auth import LoginView as LoginViewAbs
class LoginView(LoginViewAbs):
template_name = 'your_app/login.html'
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_light_auth-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d53bc39f4f3cb027704656adde0ef3123e9bd6dd259d68862038192b1b6c59cc |
|
MD5 | 0ff33160879c02d4157d29283765d2a5 |
|
BLAKE2b-256 | b56ed2e73c4b42ebac4ca6fc228f26d3740edae708644fff4dd3d136171b6ce0 |