Skip to main content

JWT authentication package for FastAPI

Project description

JWT Auth for FastAPI

This is a simple JWT authentication package for FastAPI that provides:

  • JWT token creation
  • Token verification and decoding
  • Password hashing and verification
  • FastAPI dependency injection for secure endpoints

Installation

pip install jwt-auth-provider

Usage

1. Create a token:

from jwt_auth.auth import create_access_token

# Create a JWT token
access_token = create_access_token({"sub": "username"}, secret_key, algorithm)

2. Use the dependency in FastAPI:

from fastapi import FastAPI, Depends
from jwt_auth.dependencies import get_user_from_token

app = FastAPI()

@app.get("/users/me")
def read_users_me(current_user: str = Depends(get_user_from_token)):
    return {"user": current_user}

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

jwt_auth_provider-0.2.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

jwt_auth_provider-0.2.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file jwt_auth_provider-0.2.1.tar.gz.

File metadata

  • Download URL: jwt_auth_provider-0.2.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for jwt_auth_provider-0.2.1.tar.gz
Algorithm Hash digest
SHA256 854620eaccf6e30dfe635c08f65842b6d75b82ea873a0d686be09ae700394400
MD5 f247784b2e39756103a0d806018216c0
BLAKE2b-256 2884b9af4d5db088206132ef13dcbe29820b9b99e7a2c035e22613cbd55fbd8a

See more details on using hashes here.

File details

Details for the file jwt_auth_provider-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jwt_auth_provider-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f145045a37af9e61af1bdeb3e20e8ba6ea36d5733c06787eab14229f7adfdff8
MD5 ca2788cc237f8a75e85f9ac1611283c1
BLAKE2b-256 4d6ef366fdceb04744a1cc7cd36cebbe82391cdd835990d51dffa903bb6cd965

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