Skip to main content

JWT library for fly

Project description

fly-jwt

Test

fly-jwt is JWT library for fly.

Hello World

from fly import Fly
from fly.types import Request
from fly_jwt import require_jwt

app = Fly()

def auth_handler(payload):
    return payload["username"] is "test_user"

@app.get("/")
@require_jwt(
    algorithm="HS256",
    private_key="secret",
    auth_handler=auth_handler
)
def hello(jwt_payload: Request):
    return f"Hello World {jwt_payload["username"]}"

client send request.

GET / HTTP1.1
.
. 
.
Authorization: Bearer `JWT TOKEN`

if authentication successed, execute hello function.

if authentication failed, return 401 response.

Dependency

  • fly >= 1.3.0

  • cryptography

  • PyJWT

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

fly_jwt-0.2.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page