Skip to main content

A simple library for JWT management with FastAPI

Project description

JWTs

A simple library for JWT management in FastAPI projects.

Features

  • Generate JWT tokens
  • Decode JWT tokens
  • Simple integration with FastAPI

Installation

pip install JWT_tapo44ek

How to use?

the current version is compatible with .env. The file must contain two variables:

ALGORITHM = os.environ["ALGORITHM"]

SECRET_KEY = os.environ["SECRET_KEY"]

Where ALGORITHM = your encryption algorithm. For example, "HS256".

And SECRET_KEY is a unique "salt" example ->

3d7c8e5e7342064cb8b7abe038786b48740acd737bd725ce3037263cf619f145384ed6cf33385e62910b7190ada0b1d0370e53bad1055c86bacd6f27fe811a2a57205446f8d575

To form a jwt, a dictionary with data is passed -> expire is substituted automatically for an hour. To change -> go to the library code and change the timedelta.

To decode a token, you must have the ['exp'] parameter in the pydantic scheme.

Example:

class UserJWT(BaseModel): user_id:str exp : int

Usage example:

Creating an instance of the class get_user = DecodeJWT(UserJWT)

And now we can use it in fastapi application ->

@router.get("/test", summary="JWT test") async def test(user=Depends(get_user)): """ JWT test """ return {"user_data": 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_tapo44ek-1.0.4.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

JWT_tapo44ek-1.0.4-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file jwt_tapo44ek-1.0.4.tar.gz.

File metadata

  • Download URL: jwt_tapo44ek-1.0.4.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for jwt_tapo44ek-1.0.4.tar.gz
Algorithm Hash digest
SHA256 983bbbfc991ffe9cd9f03400ed916416f9534a8e56856c85bc20c35479ab6367
MD5 105518739febfb5bcc343ad9e6bc6285
BLAKE2b-256 01e1ee6b6c45c9f40c38324da602cd61e5b616d7be07f295824365d58482fa32

See more details on using hashes here.

File details

Details for the file JWT_tapo44ek-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: JWT_tapo44ek-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for JWT_tapo44ek-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f1806b461ec9b643c70458e7c3ea50d389d1578ecd0167abd415b68f251b1f3e
MD5 ba5ea1c0d7306decaa7d7a1d1d4cf311
BLAKE2b-256 360b93d010c7a5fb8f08a7227a69755f5b7c13794ec5cb738637320fba115c72

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