| from fastapi import FastAPI,Request,HTTPException,Response |
| from pydantic import BaseModel |
| from fastapi.responses import JSONResponse |
| import uuid |
| from fastapi.middleware.cors import CORSMiddleware |
| import json |
| import base64 |
| from components.middleware import x401Kit |
|
|
|
|
|
|
|
|
| app=FastAPI() |
|
|
|
|
|
|
| origins=["*"] |
|
|
|
|
|
|
| app.add_middleware( |
| CORSMiddleware, |
| allow_origins=origins, |
| allow_credentials=True, |
| allow_methods=["*"], |
| allow_headers=["*"], |
| ) |
|
|
|
|
|
|
|
|
| app.add_middleware( |
| x401Kit, |
| protected_paths=[ |
| "/x401_auth_agent" |
| ] |
| ) |
|
|
|
|
|
|
| @app.get("/x401_auth_agent") |
| def Auth401(request:Request): |
| return {"token":""} |