Skip to content

0.13.0

Choose a tag to compare

@one-ccs one-ccs released this 07 Feb 08:52
· 5 commits to main since this release

使用 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!'}