Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 0.1.1 instead.
Reason given by maintainers: Security fix in 0.1.1

django-httponly-jwt

JWT sessions for Django in HttpOnly cookies, renewed by the server so quietly that the frontend never holds a token.

PyPI Python Django CI Coverage Licence

فارسی · Guide · Design · Example

Signing in sets two HttpOnly cookies. When the access token runs out, the server renews it on the way through - the request that found it expired is answered, and the answer carries the new one. The frontend sends requests with the cookies and goes to the sign-in screen on a 401; it never reads, stores or refreshes a token, and no script on the page can.

  • Renews when the browser has already deleted the expired cookie - the case the obvious middleware breaks.
  • Never rotates in the middleware, so two tabs renewing together do not sign each other out. Rotation is the refresh view's, and it blacklists the old token.
  • Ends a session at the next renewal when the account is switched off, or the project says so - not weeks later, when the refresh token expires.
  • Each person's session: its length (staff for a day, customers for a month), and claims such as the role, read again at every renewal.
  • Refuses at start-up what cannot work or protects nothing: SameSite=None without a CSRF check, renewal not installed, no blacklist.
  • Native apps and scripts use Authorization: Bearer and get their tokens in the body; a frontend on another site gets Django's CSRF check back.
  • Signals for an audit trail, drf-spectacular descriptions, sync and async, English and Persian.

It is a layer over djangorestframework-simplejwt: simplejwt mints and checks the tokens; how a person proves who they are stays the project's.

Installing

pip install django-httponly-jwt
# settings.py
INSTALLED_APPS = [..., 'rest_framework_simplejwt.token_blacklist', 'httponly_jwt']

MIDDLEWARE = [..., 'httponly_jwt.middleware.RenewalMiddleware', ...]

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'httponly_jwt.authentication.CookieAuthentication',
        'httponly_jwt.authentication.HeaderAuthentication',
    ],
}
# views.py - the project signs the person in, its own way, then:
from httponly_jwt.sessions import start_session


class SignInView(APIView):
    permission_classes = (AllowAny,)

    def post(self, request):
        person = verify_code(request.data['phone'], request.data['code'])
        return start_session(Response({'id': person.pk}), person, request=request)
# urls.py
from httponly_jwt.views import RefreshView, SignOutView

urlpatterns = [
    path('auth/sign-in/', SignInView.as_view()),
    path('auth/refresh/', RefreshView.as_view()),
    path('auth/sign-out/', SignOutView.as_view()),
]
// The frontend: the cookies go with every request, and 401 means sign in again.
const answer = await fetch('https://api.example.com/me/', { credentials: 'include' })

That is all of it: from there every request from the browser carries the cookies, the middleware renews the access token when it runs out, and request.user is the person. The guide has the rest - lifetimes and claims, the frontend, a frontend on another site, apps, signals, the schema, every setting and every check - and example/ has all of it running.

Django 5.2 to 6.1, Python 3.11 to 3.14.

Working on it

Every check runs through nox, the same sessions locally and in CI. With uv installed, a Python that is missing is fetched for you.

uv tool install nox
nox -s lint
nox -s types
nox -s tests

tests runs every supported Python and Django, with 100% coverage; one combination is nox -s "tests(3.13-django6.1)", and nox -l lists them all. package builds the wheel and runs the suite and the example against it. messages extracts the marked strings again and fails if the Persian catalogue is missing one; it needs gettext.

Licence

BSD 3-Clause - see LICENSE.

Metadata

Release files for django-httponly-jwt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-httponly-jwt 0.1.0
File Size Uploaded Provenance Actions
django_httponly_jwt-0.1.0.tar.gz 69.4 kB With provenance Details for django_httponly_jwt-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-httponly-jwt 0.1.0
File Interpreter ABI Platform Actions
django_httponly_jwt-0.1.0-py3-none-any.whl Python 3 none any Details for django_httponly_jwt-0.1.0-py3-none-any.whl

Total release size: 97.6 kB

Release files / django_httponly_jwt-0.1.0.tar.gz

Download URL django_httponly_jwt-0.1.0.tar.gz
Size 69.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4606334f55161995a9bd6cacf2560ed3ec8d67377e258cdd50c6ae78678b6275
BLAKE2b-256 checksum
How to use checksums
95ab09081e66b4e4f99f2d946e4f4680b436fdc4120224a3ab953cb4421b333f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / django_httponly_jwt-0.1.0-py3-none-any.whl

Download URL django_httponly_jwt-0.1.0-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53a5626302b4dbd8ec73d4b00d859c93fbb51fbaccfebaef585d502e332086c7
BLAKE2b-256 checksum
How to use checksums
0e1f050c149077a53b8ef1130863e57416d1eee1e8b1e6045d5cbd70049d4ea1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for django-httponly-jwt 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_httponly_jwt-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page