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 details)

Uploaded Source

File details

Details for the file fly_jwt-0.2.0.tar.gz.

File metadata

  • Download URL: fly_jwt-0.2.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0+

File hashes

Hashes for fly_jwt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 459dc032aaed447edf0929b66ff856fd8458f6668ebe738e3b984d3be5bfd168
MD5 a3d8ad7b96ce86bc05337cf6c5536b09
BLAKE2b-256 fcb6d80f842d4c3169db2b37c8760a38f7ca43cc00c37c03fdd561995fe63415

See more details on using hashes here.

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