Repository navigation
0.13.0
使用 FastAPI 依赖,实现基于 JWT 的 EasyAuthentication 用户身份验证扩展模块
示例:
from fastapi import FastAPI
from easy_fastapi.authentication import EasyAuthentication
app = FastAPI()
auth = EasyAuthentication(app)
@app.post('/logout')
@auth.require(require_refresh=True)
def logout():
pass
@app.get('/user')
@auth.require
def user():
return {'message': 'Hello, user!'}
@app.get('/admin')
@auth.require({'admin'})
def admin():
return {'message': 'Hello, admin!'}