Skip to main content

Reusable auth + profiles foundations for Django/DRF projects

Project description

jb-drf-auth

PyPI Version TestPyPI

Reusable authentication module for Django + Django REST Framework.

PyPI: https://pypi.org/project/jb-drf-auth/
TestPyPI: https://test.pypi.org/project/jb-drf-auth/

jb-drf-auth is a reusable foundation for authentication flows across projects, including:

  • User/profile base models (extensible)
  • OTP flows (email/SMS)
  • Login, registration, password reset, email confirmation
  • Multi-profile support
  • Provider-based SMS/email architecture
  • Configurable behavior via Django settings

Installation

pip install jb-drf-auth

Add jb_drf_auth and rest_framework to INSTALLED_APPS.

Documentation

  • Main docs index: docs/README.md
  • Getting started and configuration: docs/getting-started.md
  • API contract (endpoint by endpoint): docs/API_CONTRACT.md
  • Social authentication guide: docs/social-auth.md
  • Migration guide: docs/migration.md
  • i18n integration guide: docs/i18n.md
  • Release guide: docs/release.md
  • Roadmap: roadmap.md

Quick Start

  1. Configure concrete models in your project (User, Profile, Device, OtpCode, logs).
  2. Configure JB_DRF_AUTH settings (minimal real-world example):
JB_DRF_AUTH = {
    "PROFILE_MODEL": "authentication.Profile",
    "DEVICE_MODEL": "authentication.Device",
    "OTP_MODEL": "authentication.OtpCode",
    "SMS_LOG_MODEL": "authentication.SmsLog",
    "EMAIL_LOG_MODEL": "authentication.EmailLog",
    "FRONTEND_URL": env("JB_DRF_AUTH_FRONTEND_URL", default="http://localhost:3000"),
    "DEFAULT_FROM_EMAIL": "no-reply@your-domain.com",
    "AUTHENTICATION_TYPE": "both",  # "email", "username", "both"
    "AUTH_SINGLE_SESSION_ON_MOBILE": env.bool(
        "AUTH_SINGLE_SESSION_ON_MOBILE", default=False
    ),
    "MOBILE_NOTIFICATION_TOKEN_REQUIRED": env.bool(
        "MOBILE_NOTIFICATION_TOKEN_REQUIRED", default=False
    ),
    "ADMIN_BOOTSTRAP_TOKEN": env("JB_DRF_AUTH_ADMIN_BOOTSTRAP_TOKEN", default="super-secret-token"),
    "PROFILE_PICTURE_UPLOAD_TO": "uploads/users/profile-pictures",
    "PERSON_ID_DOCUMENTS_UPLOAD_TO": "uploads/people/id-documents",
    "PROFILE_ROLE_CHOICES": (
        ("PATIENT", "Patient"),
        ("DOCTOR", "Doctor"),
        ("ADMIN", "Admin"),
    ),
    "DEFAULT_PROFILE_ROLE": "PATIENT",
    "SMS_SENDER_ID": "YourBrand",
    "SMS_OTP_MESSAGE": "Tu codigo para acceder a Mentalysis es {code}. Expira en {minutes} minutos.",
}

If you use env(...)/env.bool(...), ensure environ.Env() is configured in your settings module. Recommended convention: use JB_DRF_AUTH_ prefix for library-related env vars. 3. Mount URLs:

from django.urls import include, path

urlpatterns = [
    path("auth/", include("jb_drf_auth.urls")),
]
  1. Run migrations in the integrator project.

For complete setup examples (including full JB_DRF_AUTH dict), see docs/getting-started.md.

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

jb_drf_auth-0.1.12.tar.gz (47.7 kB view details)

Uploaded Source

Built Distribution

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

jb_drf_auth-0.1.12-py3-none-any.whl (73.3 kB view details)

Uploaded Python 3

File details

Details for the file jb_drf_auth-0.1.12.tar.gz.

File metadata

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

File hashes

Hashes for jb_drf_auth-0.1.12.tar.gz
Algorithm Hash digest
SHA256 7325a1842dea00b91620695d581d2b512be33c676953b837dab205d67fe54806
MD5 096f3cdce2f6e29697133b78dc05a92b
BLAKE2b-256 271bdd90e2a7e8b4a92b5556caea0c3b83594975015f27952aca0c6dd1adaf4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for jb_drf_auth-0.1.12.tar.gz:

Publisher: pypi-publish.yml on joelbarron/jb-drf-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 jb_drf_auth-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: jb_drf_auth-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 73.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jb_drf_auth-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 9fce1719a7acce101dc6e8fef2675842d0d27a6e92b05b3fc6686278808b524f
MD5 9bd53b6095bc51f88508e7e6ba34494a
BLAKE2b-256 53de0a7f0b10ceb91fb9ae498d32004d76a25d79eebbf42fa6608a121b48f8e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for jb_drf_auth-0.1.12-py3-none-any.whl:

Publisher: pypi-publish.yml on joelbarron/jb-drf-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