Skip to main content

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

Project description

django-light-auth

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

Install

pip3 install -U django-light-auth

Basic Usage

settings.py

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

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

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.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

django_light_auth-0.2.2-py2.py3-none-any.whl (6.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-light-auth-0.2.2.tar.gz.

File metadata

  • Download URL: django-light-auth-0.2.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for django-light-auth-0.2.2.tar.gz
Algorithm Hash digest
SHA256 82c27e794a23adcc316f1d015126b368422633b01dd7816f7b58968e7924917e
MD5 1989da0d38a307a37cbcc220864f3469
BLAKE2b-256 913a843ddfb747241861fb3bd4f1f799e9a15d78f3a1ea4bb5658b41d6a571e2

See more details on using hashes here.

File details

Details for the file django_light_auth-0.2.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_light_auth-0.2.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dcf2e05083a600a0be09ad591d18a5cff391d789d15428ae50f63c64422c9bae
MD5 1d19d515248e76192f6ca02d62d77f40
BLAKE2b-256 298fdbe8810d867cf652a98f793d6108688f67110f2178245e1b712252b51490

See more details on using hashes here.

Supported by

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