or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

account-management.mdcore-config.mdheadless-api.mdindex.mdmfa.mdsocial-authentication.mdtemplate-system.mduser-sessions.md
tile.json

tessl/pypi-django-allauth

Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/django-allauth@65.11.x

To install, run

npx @tessl/cli install tessl/pypi-django-allauth@65.11.0

index.mddocs/

Django-Allauth

A comprehensive Django authentication library providing integrated local and social authentication, account management, multi-factor authentication, and headless API support. Django-allauth serves as a complete authentication solution for Django applications, supporting everything from basic login/registration to enterprise-grade authentication flows with 50+ social providers.

Package Information

  • Package Name: django-allauth
  • Language: Python
  • Framework: Django
  • Installation: pip install django-allauth
  • Version: 65.11.1

Core Imports

import allauth

Common Django settings and URL configuration:

# settings.py
INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.messages',
    'allauth',
    'allauth.account',
    # Optional components
    'allauth.socialaccount',
    'allauth.mfa',
    'allauth.headless',
    'allauth.usersessions',
]

# urls.py
from django.urls import path, include

urlpatterns = [
    path('accounts/', include('allauth.urls')),
]

Basic Usage

# Basic account setup
from allauth.account.models import EmailAddress
from allauth.account.adapter import get_adapter
from django.contrib.auth import get_user_model

User = get_user_model()

# Create user with email verification
adapter = get_adapter()
user = adapter.new_user(request)
adapter.save_user(request, user, form)

# Add and verify email
email_address = EmailAddress.objects.add_email(request, user, 'user@example.com')
email_address.send_confirmation(request)

# Social authentication setup
from allauth.socialaccount.models import SocialApp

# Configure social provider (e.g., Google)
google_app = SocialApp.objects.create(
    provider='google',
    name='Google OAuth2',
    client_id='your-client-id',
    secret='your-client-secret'
)

Architecture

Django-allauth follows Django's modular app architecture with several key components:

  • Core Module: Version info, utilities, and configuration management
  • Account Management: Local authentication, email verification, password management
  • Social Authentication: OAuth 1.0/2.0 integration with 50+ providers
  • Multi-Factor Authentication: TOTP, WebAuthn, recovery codes
  • Headless API: REST API for mobile/SPA applications
  • User Sessions: Cross-device session management
  • Identity Provider: OIDC provider capabilities

The library uses Django's adapter pattern for customization, comprehensive signal system for extensibility, and follows Django best practices for models, views, forms, and URL configuration.

Capabilities

Core Configuration and Utilities

Core configuration management, utility functions, and version information. Provides settings management, username generation, URL building, and other foundational functionality.

class AppSettings:
    SITES_ENABLED: bool
    SOCIALACCOUNT_ENABLED: bool
    MFA_ENABLED: bool
    HEADLESS_ENABLED: bool

def generate_unique_username(txts: list, regex: str = None) -> str: ...
def build_absolute_uri(request, location: str, protocol: str = None) -> str: ...
def import_attribute(path: str): ...

Core Configuration

Account Management

Local user authentication, registration, email verification, password management, and account settings. Handles traditional Django authentication flows with enhanced email and phone verification.

class EmailAddress:
    user: User
    email: str
    verified: bool
    primary: bool
    
class LoginView(FormView): ...
class SignupView(FormView): ...
class PasswordResetView(FormView): ...

def get_adapter() -> AccountAdapter: ...

Account Management

Social Authentication

OAuth 1.0/2.0 integration supporting 50+ providers including Google, Facebook, GitHub, Twitter, and enterprise providers. Provides complete social login flows with account linking capabilities.

class SocialApp:
    provider: str
    provider_id: str
    client_id: str
    secret: str
    settings: dict

class SocialAccount:
    user: User
    provider: str
    uid: str
    extra_data: dict

def get_adapter() -> SocialAccountAdapter: ...

Social Authentication

Multi-Factor Authentication

TOTP authenticators, WebAuthn hardware keys, recovery codes, and MFA management flows. Provides enterprise-grade security with multiple authentication factor support.

class Authenticator:
    user: User
    type: str
    data: dict
    
class RecoveryCode:
    user: User
    code: str
    used_at: datetime

Multi-Factor Authentication

Headless API

REST API endpoints for mobile and single-page applications. Provides JSON-based authentication flows without traditional Django templates and forms.

class Flow(str, Enum):
    LOGIN = "login"
    SIGNUP = "signup" 
    VERIFY_EMAIL = "verify_email"
    PASSWORD_RESET_BY_CODE = "password_reset_by_code"
    
class Client(str, Enum):
    APP = "app"
    BROWSER = "browser"

Headless API

User Session Management

Multi-device session tracking, session metadata collection, and cross-device logout capabilities. Provides visibility and control over user sessions across different devices and browsers.

class UserSession:
    user: User
    ip: str
    user_agent: str
    created_at: datetime
    last_seen_at: datetime

User Sessions

Template System

Comprehensive template tag library with element-based UI framework, slot system for template composition, and customizable layouts for authentication UI.

@register.tag(name="element")
def do_element(parser, token): ...

@register.tag(name="slot") 
def do_slot(parser, token): ...

@register.tag(name="setvar")
def do_setvar(parser, token): ...

Template System

Types

from typing import Optional, Dict, Any, List
from django.contrib.auth.models import AbstractUser
from django.http import HttpRequest

User = AbstractUser

class AccountAdapter:
    def new_user(self, request: HttpRequest) -> User: ...
    def save_user(self, request: HttpRequest, user: User, form) -> None: ...
    def clean_username(self, username: str, shallow: bool = False) -> str: ...

class SocialAccountAdapter:
    def new_user(self, request: HttpRequest, sociallogin) -> User: ...
    def populate_user(self, request: HttpRequest, sociallogin, data: Dict[str, Any]) -> User: ...

class EmailConfirmation:
    email_address: EmailAddress
    created: datetime
    sent: datetime
    key: str