Skip to main content

A Django app for multi-token authentication, and some other stuff.

Project description

Authentication

A Django app for multi-token authentication.

Installation

pip install authentication

Usage

Add authentication to your INSTALLED_APPS in your Django settings.

INSTALLED_APPS = [
   'authentication',
]

Custom User Validation

To add custom validation to the login process, follow these steps:

  1. Define the Custom Validation Function:

    Create a custom validation function in a module. This function should accept a user object and perform the necessary validation.

    # authentication/custom_validations.py
    from django.core.exceptions import PermissionDenied
    from django.utils.translation import gettext as _
    
    def custom_user_validation(user):
        if not user.is_active:
            raise PermissionDenied(_("User is not active."), 'inactive_user')
    
  2. Update the Settings:

    In your settings.py file, add the MORE_USER_VALIDATION setting and set it to the path of your custom validation function.

    # cha_auth/settings.py
    MORE_USER_VALIDATION = 'authentication.custom_validations.custom_user_validation'
    

By following these steps, you can add custom validation to the login process without modifying the URL configuration. Users can specify their custom validation function in the MORE_USER_VALIDATION setting, and it will be called during the login process.

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

cha_authentication-0.5.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

cha_authentication-0.5.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file cha_authentication-0.5.0.tar.gz.

File metadata

  • Download URL: cha_authentication-0.5.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for cha_authentication-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0c0b1c24676c3c40abc395ae8094a25e2231071152a2f818e1ea3176aaadb97a
MD5 3d1503521a543fefc0e85b45130eeda4
BLAKE2b-256 e125f648bdbcb6780ce05ed7c3c83b18b6c429cb04f3a42042c5c9f3eef2d0b1

See more details on using hashes here.

File details

Details for the file cha_authentication-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cha_authentication-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5135c7a4a70434c29b047458c6c8ec9e49c5c823236de0649a02f58c51a2255
MD5 93e30fc48324e61e7b5c857f98f741a8
BLAKE2b-256 14e25b048308a07fac32cdf5944b7c58ec4d5aefaa4fbfb61fec410252220d05

See more details on using hashes here.

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