django-light-auth-0.2.2
توضیحات
Django Lightweight Authentication without models and databases, only depend on the Django's SessionMiddleware.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | django-light-auth-0.2.2 |
| نام | django-light-auth |
| نسخه کتابخانه | 0.2.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Rex Zhang |
| ایمیل نویسنده | rex.zhang@gmail.com |
| آدرس صفحه اصلی | https://github.com/rexzhang/django-light-auth |
| آدرس اینترنتی | https://pypi.org/project/django-light-auth/ |
| مجوز | - |
# django-light-auth
[](https://pypi.org/project/django-light-auth/)
[](https://pypi.org/project/django-light-auth/)
[](https://pypi.org/project/django-light-auth/)
> Django Lightweight Authentication without models and databases, only depend on the Django's SessionMiddleware.
# Install
```shell
pip3 install -U django-light-auth
```
# Basic Usage
## `settings.py`
```python
INSTALLED_APPS = [
# ...
# 'django.contrib.auth',
'django_light_auth',
# ...
]
MIDDLEWARE = [
# ...
'django.contrib.sessions.middleware.SessionMiddleware',
# 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_light_auth.LightAuthMiddleware'
# ...
]
# Session
SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'
# django-light-auth
LIGHT_AUTH_VALIDATE_FUNC = 'your_app.auth.validate_func'
```
## `urls.py`
```python
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`
```python
#
# 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`
```python
from django_light_auth import LoginView as LoginViewAbs
class LoginView(LoginViewAbs):
template_name = 'your_app/login.html'
```
# History
## v0.2.2 - 20220809
- Compatible Django 4.1+
نیازمندی
| مقدار | نام |
|---|---|
| - | django |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.5 | Python |
نحوه نصب
نصب پکیج whl django-light-auth-0.2.2:
pip install django-light-auth-0.2.2.whl
نصب پکیج tar.gz django-light-auth-0.2.2:
pip install django-light-auth-0.2.2.tar.gz