Skip to main content

Django Lightweight Authentication without models and databases, only depend on the signed cookies and the Django's SessionMiddleware.

Project description

django-light-auth

PyPI - Version Python Version from PEP 621 TOML PyPI - Django Version PyPI - Downloads

Django Lightweight Authentication without models and databases, only depend on the signed cookies and the Django's SessionMiddleware.

Install

pip3 install -U django-light-auth

Usage

Basic Usage

settings.py

INSTALLED_APPS = [
    # ...
    # 'django.contrib.auth',
    'django_light_auth.apps.DjangoLightAuthConfig',

    # ...
]

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

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'

History

0.2.3 - 20251112

  • Maintenance release

v0.2.2 - 20220809

  • Compatible Django 4.1+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_light_auth-0.2.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_light_auth-0.2.3-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file django_light_auth-0.2.3.tar.gz.

File metadata

  • Download URL: django_light_auth-0.2.3.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_light_auth-0.2.3.tar.gz
Algorithm Hash digest
SHA256 55e516ce84aef4e895814189397a36bba8c516c9bd3b813b1bb0dac7e6ee2847
MD5 ba98d452e6f0debb82b192579fdfc74f
BLAKE2b-256 617769969f92f47fd78a69c0d4137760bac2d0805ef7080806654f65c5750325

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_light_auth-0.2.3.tar.gz:

Publisher: release-pypi.yaml on rexzhang/django-light-auth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_light_auth-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_light_auth-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a2e06575fbf6bcbbe600cf211cf14929748c0f7fdf7d44e997b9d5e271c94d8
MD5 039ff4d01887bb29d2b922c62b25f6f4
BLAKE2b-256 e766556990ed508ff834c1a7ac88dfa56cd7121bd4cc15786b65a6e8bc193d54

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_light_auth-0.2.3-py3-none-any.whl:

Publisher: release-pypi.yaml on rexzhang/django-light-auth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page