Skip to main content

A Django authentication boilerplate with OTP and role-based access control

Project description

django-auth-app

A Django authentication boilerplate with OTP and role-based access control. This package provides a robust and reusable authentication system, including basic registration, login/logout, password management, OTP setup, email verification, and social authentication integration.

Features

  • Basic Authentication: Registration, login, logout, password change.
  • OTP Verification: For registration and password reset.
  • Email Verification: Through SMTP.
  • Social Authentication: Google and Facebook integration.
  • Role-Based Access Control (RBAC): Differentiated roles for custom and social registrations.
  • Swagger Documentation: API documentation.
  • JWT Token Authentication: For API access.

Installation

  1. Install the package:

    pip install django-auth-app
    
  2. Add the app to your Django project:

    In your settings.py, add auth_app to your INSTALLED_APPS:

    INSTALLED_APPS = [
        # Other installed apps
        'auth_app',
        'rest_framework',
        'drf_yasg',
        
    ]
    
  3. Configure SMTP for email sending:

    Add your SMTP settings to settings.py:

    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    EMAIL_HOST = 'smtp.example.com'
    EMAIL_PORT = 587
    EMAIL_USE_TLS = True
    EMAIL_HOST_USER = 'your_email@example.com'
    EMAIL_HOST_PASSWORD = 'your_email_password'
    
  4. Set up JWT authentication:

    Add the following to settings.py:

    REST_FRAMEWORK = {
        'DEFAULT_AUTHENTICATION_CLASSES': [
            'rest_framework_simplejwt.authentication.JWTAuthentication',
        ],
    }
    
  5. Include the URL configurations:

    Add the following to your project's urls.py:

    from django.urls import path, include
    from auth_app import views
    
    urlpatterns = [
        path('auth/', include('auth_app.urls')),
        # Other URLs
    ]
    
  6. Run migrations:

    python manage.py makemigrations
    python manage.py migrate
    

Usage

Web Views

  • Registration: /register/
  • Login: /login/
  • Logout: /logout/
  • Password Change: /password-change/
  • Password Reset: /password-reset/
  • OTP Verification: /otp-verify/

API Endpoints

  • Register: api/register/
  • Login: api/login/
  • OTP Verify: api/otp-verify/
  • Password Change: api/password-change/
  • Password Reset: api/password-reset/

Swagger Documentation

  • Swagger UI: /docs/

Development

To contribute to the development of django-auth-app, clone the repository and install the dependencies:

git clone https://github.com/sajan69/django-auth-boilerplate.git
cd django-auth-boilerplate
pip install -r requirements.txt

Testing

To run tests, use:

pytest

License

MIT License. See the LICENSE file for details.

Author

Sajan Adhikari
sajana46@gmail.com


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_auth_app-0.3.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

django_auth_app-0.3-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file django_auth_app-0.3.tar.gz.

File metadata

  • Download URL: django_auth_app-0.3.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for django_auth_app-0.3.tar.gz
Algorithm Hash digest
SHA256 008dedfe7a6b0ea423ea4e3c6d4203e02fb127de518be72eaeb28957bf0dc858
MD5 a6a590a3e5d8e8511cfcdb0b1d4b413e
BLAKE2b-256 ba262aa7e57ad207a84f15e663eb38a6170f8e7332369ee58a0c1e312d389873

See more details on using hashes here.

File details

Details for the file django_auth_app-0.3-py3-none-any.whl.

File metadata

  • Download URL: django_auth_app-0.3-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for django_auth_app-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4582558f4a37c5bb56d62bafa661475f145d8051a2cd87244d79cb02aba512e5
MD5 716c74f6ad5f74de72a576b2d64c9493
BLAKE2b-256 246c3d61f2f002b1ab7f877c09838022f4a573da5ac85e8d6e79a3314d70e866

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