fly-jwt-0.2.0
توضیحات
JWT library for fly
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | fly-jwt-0.2.0 |
| نام | fly-jwt |
| نسخه کتابخانه | 0.2.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | tatsuya.s |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | https://github.com/tatsuya4649/fly_jwt |
| آدرس اینترنتی | https://pypi.org/project/fly-jwt/ |
| مجوز | MIT |
# fly-jwt

fly-jwt is JWT library for [fly](https://github.com/tatsuya4649/fly).
## Hello World
```python
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.
```bash
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
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl fly-jwt-0.2.0:
pip install fly-jwt-0.2.0.whl
نصب پکیج tar.gz fly-jwt-0.2.0:
pip install fly-jwt-0.2.0.tar.gz