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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jwt_tapo44ek-1.0.6.tar.gz.
File metadata
- Download URL: jwt_tapo44ek-1.0.6.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d74db94d41b51952eb0e8c679958beb9affa204e5d55415a4bbd32cc552c61a9
|
|
| MD5 |
426a5d5c595048ff7a3d16925ab63c02
|
|
| BLAKE2b-256 |
942428bdc68020cc3d538ea6ab07eed75580d3381e4d16621f66ee2d446fb810
|
File details
Details for the file JWT_tapo44ek-1.0.6-py3-none-any.whl.
File metadata
- Download URL: JWT_tapo44ek-1.0.6-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d754f3402cf8611c1d5040e48f54a7cb9494f83f05e118b2823cf2962caa025
|
|
| MD5 |
44eb49fd7de25ae71617139d8745c95d
|
|
| BLAKE2b-256 |
d79b94d72830cab7ce67cffcf4ae53b82fc5fe71180e1c18fcb6c8470cd3c01b
|