Skip to main content

JWT authentication plugin for python-auth-proxy

Project description

JWT Authentication Plugin for auth-proxy

A JWT (JSON Web Token) authentication plugin for the Modular Authenticating Reverse Proxy.

Installation

pip install auth-proxy-jwt

Features

  • Validates JWT tokens from the Authorization header
  • Configurable secret key and algorithm
  • Optional audience and issuer validation
  • Customizable claims mapping
  • Forwards user identity and role information to backend services

Configuration

Add the JWT plugin to your auth-proxy configuration:

auth_plugins:
  jwt:
    secret: "your-secret-key"
    algorithm: "HS256"
    audience: "your-api"
    issuer: "your-identity-provider"
    require_exp: true
    leeway: 10
    header_prefix: "Bearer"
    user_claim: "sub"
    role_claim: "roles"
    forward_claims: ["email", "permissions"]

paths:
  - path: "^/api/.*$"
    regex: true
    authenticate: true
    plugins: [jwt]

Configuration Options

Option Description Default
secret Secret key for validating token signatures (required)
algorithm JWT algorithm to use "HS256"
audience Expected audience claim null
issuer Expected issuer claim null
require_exp Whether to require expiration time true
leeway Leeway in seconds for expiration time 0
header_prefix Authorization header prefix "Bearer"
user_claim Claim to use for user identity "sub"
role_claim Claim to use for role information "role"
forward_claims Additional claims to forward as headers []

Headers Added to Backend Requests

When authentication succeeds, the plugin adds the following headers to the proxied request:

  • X-Auth-User: The user identity from the token (from the configured user_claim)
  • X-Auth-Role: The role or roles from the token (from the configured role_claim)
  • X-Auth-Claim-{name}: Additional claims specified in forward_claims

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

auth_proxy_jwt-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

auth_proxy_jwt-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: auth_proxy_jwt-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for auth_proxy_jwt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a04f4273bbb9c1041146b1a53b7b0bb2c4e846a70b4a7483deeca405c11828e8
MD5 3a65abf2a89966149c398c54f0129c6c
BLAKE2b-256 bbc7d5cd081d505e26c7ce4611c20403dc94b67c82f0f0ee5befc0f242b9af15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: auth_proxy_jwt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for auth_proxy_jwt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64353f11681c356d173687e49a74531fd73741e26d6ed1878a679f0f1e59cccf
MD5 9f73b045064ca2da3cdd57f00bd66240
BLAKE2b-256 6aa660d95aa2c4569e90500302803f043ab6cdd18fee9e0eb7c28dbbca3cef0d

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