Skip to main content

Web727Token

A secure-by-default authentication framework for Django, Django REST Framework, and React.

Install once. Protect every request. Keep authentication out of your application code.

pip install web727token
npm install web727token

Why Web727Token?

Traditional authentication libraries provide JWT utilities and expect developers to wire everything together.

Web727Token takes a different approach.

It is a complete authentication framework that centralizes authentication, authorization, session management, refresh-token rotation, audit logging, device tracking, and rate limiting behind a single middleware.

Your application works with authenticated users—not authentication infrastructure.

Traditional JWT Libraries Web727Token
Configure authentication on every view Install middleware once
Developers work directly with JWTs JWT is completely hidden
Manual authentication decorators Middleware authenticates every request
Manual Axios interceptors Included React SDK
Refresh logic written manually Automatic refresh rotation
Session management varies by project Built-in
Device tracking is custom Built-in
Audit logging is custom Built-in
Logout implementation differs Standardized

Features

Authentication

  • Middleware-driven authentication
  • JWT hidden behind the framework
  • Automatic authentication for every request
  • Django & Django REST Framework support
  • Custom Django User model support

Security

  • Access token expiration
  • Refresh token rotation
  • Refresh-token reuse detection
  • Automatic session invalidation
  • Per-user account lockout
  • Per-IP rate limiting
  • Device tracking
  • Audit logging
  • Configurable token lifetimes

Frontend

  • React SDK
  • Automatic Authorization header attachment
  • Silent token refresh
  • Automatic retry after refresh
  • Session restoration
  • React authentication hook

Architecture

Web727Token does not introduce another authentication standard.

JWT is simply an internal implementation detail.

Only tokens.py understands JWT.

Everything else—including your application code—works only with authenticated users.

Client
   │
   ▼
Web727 React SDK
   │
   ▼
Authorization Header
   │
   ▼
Web727Middleware
   │
   ▼
request.web727
   │
   ▼
Application Code

Requirements

  • Python 3.10+
  • Django 5+
  • Django REST Framework
  • React 18+ (Frontend SDK)

Installation

Backend

pip install web727token

Frontend

npm install web727token

Run migrations:

python manage.py migrate

Backend Quick Start

Install the application.

# settings.py

INSTALLED_APPS = [
    ...
    "web727token",
]

Install the middleware.

MIDDLEWARE = [
    ...
    "web727token.middleware.Web727Middleware",
]

Enable Web727Token.

WEB727_ENABLED = True

Register framework URLs.

# urls.py

urlpatterns = [
    path("web727/", include("web727token.urls")),
    path("api/", include("myapp.urls")),
]

That's all.

Every request under /api/ is authenticated automatically.

No

  • authentication_classes
  • permission_classes
  • IsAuthenticated

are required.


Using the Authenticated User

from rest_framework.views import APIView
from rest_framework.response import Response


class CustomerAPIView(APIView):

    def get(self, request):
        return Response({
            "id": request.web727.user.id,
            "username": request.web727.user.username,
        })

Every authenticated request automatically provides:

request.web727.user
request.web727.session
request.web727.device
request.web727.roles
request.web727.permissions
request.user

Frontend Quick Start

import { Web727 } from "web727token";

Web727.init();

await Web727.login("alice", "hunter2");

const profile = await Web727.client.get("/api/profile");

await Web727.logout();

Or use the React hook.

import { useWeb727Auth } from "web727token";

function LoginButton() {

    const {
        isAuthenticated,
        login,
        logout,
    } = useWeb727Auth();

    return isAuthenticated
        ? <button onClick={logout}>Logout</button>
        : <button onClick={() => login("alice", "hunter2")}>Login</button>;
}

The SDK automatically:

  • Stores tokens
  • Attaches Authorization headers
  • Refreshes expired access tokens
  • Retries failed requests
  • Persists rotated refresh tokens

No Axios interceptor configuration is required.


Built-in Framework Endpoints

These endpoints are provided by Web727Token.

Method Endpoint Description
POST /web727/login Authenticate and create a session
POST /web727/logout Logout the current session
POST /web727/refresh Rotate the refresh token
GET /web727/me Current authenticated user
GET /web727/session List active sessions
GET /web727/session/{id} Get session details (planned)
DELETE /web727/session/{id} Revoke a specific session (planned)
DELETE /web727/session Logout from all devices (planned)
PUT /web727/change-password Change password
PATCH /web727/profile Update authenticated user profile (planned)
OPTIONS /web727/* Supported automatically by Django
HEAD /web727/* Supported automatically by Django

Supported HTTP Methods

Web727Middleware authenticates every incoming request regardless of HTTP method.

Supported methods include:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
  • OPTIONS
  • HEAD

Once authenticated, request.web727 is available for every supported request.


What's Included

Web727Token provides:

  • Authentication middleware
  • Login, logout and token refresh endpoints
  • JWT token engine
  • Session management
  • Device tracking
  • Login history
  • Audit logging
  • Role and permission support
  • React SDK with automatic token management

Current Status

Backend

Completed

  • Middleware authentication
  • JWT token engine
  • Session management
  • Refresh token rotation
  • Refresh-token reuse detection
  • Automatic session invalidation
  • Login history
  • Device tracking
  • Audit logging
  • Per-user account lockout
  • Per-IP rate limiting
  • Role-based authorization
  • Six built-in authentication endpoints

22 / 22 pytest-django tests passing

Verified through automated tests and successful package builds.


Frontend

Completed

  • React SDK
  • Login
  • Logout
  • Session restoration
  • Automatic Authorization header
  • Automatic refresh
  • Automatic retry after refresh
  • Refresh-token persistence
  • React authentication hook
  • Rollup CJS & ESM builds

14 / 14 Vitest tests passing


Roadmap

Planned improvements include:

  • Cookie-based authentication documentation
  • CSRF guidance for cookie deployments
  • Session management UI example
  • Device management UI example
  • GitHub Actions CI/CD
  • PyPI publishing workflow
  • npm publishing workflow

Philosophy

Web727Token is not another JWT library.

JWT is deliberately isolated inside tokens.py.

Application developers never need to:

  • Parse JWTs
  • Validate JWTs
  • Refresh JWTs
  • Attach Authorization headers
  • Configure authentication decorators
  • Write Axios interceptors

Instead, developers simply work with authenticated users through request.web727.


License

MIT License

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web727token-1.0.1.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

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

web727token-1.0.1-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file web727token-1.0.1.tar.gz.

File metadata

  • Download URL: web727token-1.0.1.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for web727token-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c5825ccdef4b6f30be77b5ba0426f2ac92a75e3cd0ef2e5444f3ba407c310932
MD5 7f7a3b590528f57fbbd1e4e967f52127
BLAKE2b-256 2f9fa95df0bb5397f0b18229888c2b5be4e944e45d83c63e35eeb32c56091d7c

See more details on using hashes here.

File details

Details for the file web727token-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: web727token-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for web727token-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1fedb561a72f9108d49ddc7e49f134e6d2589d5e7daae6500138d5cf601cb57a
MD5 6134d02a12b567cd422e33bfe37f9d6f
BLAKE2b-256 e5ab620297c015a132743d53c4218f43d17b1462546b053e7f20389310c7f11a

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 Sentry Error logging StatusPage Status page