Skip to main content

Django REST Framework authentication using PASETO (pyseto)

Project description

drf-pyseto

Simple PASETO (v4.local) authentication for Django REST Framework using pyseto.

Targeted for Django 4.2–6.x and Python 3.10–3.14.

Install

pip install drf-pyseto

Dev Install

pip install -e ".[test]"

Settings

DRF_PYSETO = {
    "KEY": "<32-byte key or base64url>",
    "ACCESS_LIFETIME": 300,  # seconds
    "REFRESH_LIFETIME": 86400,  # seconds
    "USER_ID_FIELD": "id",
    "USER_ID_CLAIM": "user_id",
    "TOKEN_TYPE_CLAIM": "typ",
    "AUTH_HEADER_TYPE": "Bearer",
    # Optional:
    # "ISSUER": "your-service",
    # "AUDIENCE": "your-clients",
}

URLs

from django.urls import path, include

urlpatterns = [
    path("api/auth/", include("drf_pyseto.urls")),
]

DRF Authentication

REST_FRAMEWORK = {
    "DEFAULT_AUTHENTICATION_CLASSES": [
        "drf_pyseto.authentication.PASETOAuthentication",
    ]
}

Endpoints

  • POST /token/ with username and password
  • POST /token/refresh/ with refresh

Tests

pytest

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

drf_pyseto-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

drf_pyseto-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file drf_pyseto-0.1.0.tar.gz.

File metadata

  • Download URL: drf_pyseto-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for drf_pyseto-0.1.0.tar.gz
Algorithm Hash digest
SHA256 489f9b36cd4ec187f76d147755de294c13e418fa85ea474ff60ff6cf9e88f0f5
MD5 c3a773a69892df36f6786470d71ff3c9
BLAKE2b-256 a52187845b059827c983c090f8302ef1f5efe53dd37e1a8bf8bd6563a00754c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_pyseto-0.1.0.tar.gz:

Publisher: release.yml on p-r-a-v-i-n/drf-pyseto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_pyseto-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: drf_pyseto-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for drf_pyseto-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57b632d1cec39c365895528ab5515ef66de523eee4992e5077c8cd5e791aa045
MD5 5a078601458f0e6c6395848fbf6e8e6a
BLAKE2b-256 57c429933ade4abe3eac73cfb1cd98437c00dc0e09ed9554ac9af5ca252a8873

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_pyseto-0.1.0-py3-none-any.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-pyseto

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