fastapi-jwt-0.1.8
توضیحات
`FastAPI` extension for JTW Auth
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | fastapi-jwt-0.1.8 |
| نام | fastapi-jwt |
| نسخه کتابخانه | 0.1.8 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Konstantin Chernyshev |
| ایمیل نویسنده | kdchernyshev@gmail.com |
| آدرس صفحه اصلی | https://github.com/k4black/fastapi-jwt |
| آدرس اینترنتی | https://pypi.org/project/fastapi-jwt/ |
| مجوز | - |
# fastapi-jwt
[](https://github.com/k4black/fastapi-jwt/actions/workflows/test.yml)
[](https://github.com/k4black/fastapi-jwt/actions/workflows/publish.yml)
[](https://codecov.io/gh/k4black/fastapi-jwt)
[](https://pypi.org/project/fastapi-jwt/)
FastAPI native extension, easy and simple JWT auth
---
**Documentation:** [k4black.github.io/fastapi-jwt](https://k4black.github.io/fastapi-jwt/)
**Source Code:** [github.com/k4black/fastapi-jwt](https://github.com/k4black/fastapi-jwt/)
## Features
* OpenAPI schema generation
* Native integration with FastAPI
* Access/Refresh JWT
* JTI
* Cookie setting
## Installation
You can access package [fastapi-jwt in pypi](https://pypi.org/project/fastapi-jwt/)
```shell
pip install fastapi-jwt
```
## Usage
This library made in fastapi style, so it can be used as standard security features
```python
from fastapi import FastAPI, Security
from fastapi_jwt import JwtAuthorizationCredentials, JwtAccessBearer
app = FastAPI()
access_security = JwtAccessBearer(secret_key="secret_key", auto_error=True)
@app.post("/auth")
def auth():
subject = {"username": "username", "role": "user"}
return {"access_token": access_security.create_access_token(subject=subject)}
@app.get("/users/me")
def read_current_user(
credentials: JwtAuthorizationCredentials = Security(access_security),
):
return {"username": credentials["username"], "role": credentials["role"]}
```
For more examples see usage docs
## Alternatives
* FastAPI docs suggest [writing it manually](https://fastapi.tiangolo.com/tutorial/security/oauth2-jwt/), but
* code duplication
* opportunity for bugs
* There is nice [fastapi-jwt-auth](https://github.com/IndominusByte/fastapi-jwt-auth/), but
* poorly supported
* not "FastAPI-style" (not native functions parameters)
## FastAPI Integration
There it is open and maintained [Pull Request #3305](https://github.com/tiangolo/fastapi/pull/3305) to the `fastapi` repo. Currently, not considered.
## Requirements
* `fastapi`
* `python-jose[cryptography]`
نیازمندی
| مقدار | نام |
|---|---|
| >=0.50.0 | fastapi |
| >=3.3.0 | python-jose[cryptography] |
| <2.0.0,>=1.2.0 | mkdocs |
| <9.0.0,>=8.0.0 | mkdocs-material |
| <1.0.0,>=0.1.0 | MkAutoDoc |
| <1.0.0,>=0.4.5 | lazydocs |
| <4.0.0,>=3.2.0 | mkdocs-include-markdown-plugin |
| <3.0.0,>=2.6.0 | mkdocs-awesome-pages-plugin |
| <2.0.0,>=1.1.0 | mike |
| <7.0.0,>=6.0.0 | pytest |
| <4.0.0,>=3.0.0 | pytest-cov |
| <4.0.0,>=3.0.0 | pytest-mock |
| <3.0.0,>=2.25.0 | requests |
| ==21.11b1 | black |
| >=0.910 | mypy |
| <8.0.0,>=4.0.0 | flake8 |
| <6.0.0,>=5.10.1 | isort |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl fastapi-jwt-0.1.8:
pip install fastapi-jwt-0.1.8.whl
نصب پکیج tar.gz fastapi-jwt-0.1.8:
pip install fastapi-jwt-0.1.8.tar.gz