mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
resolved local api validation flow
This commit is contained in:
parent
6193948b2f
commit
09df555b2b
4 changed files with 8 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from fastapi import Depends, HTTPException, status
|
||||
from fastapi import Depends, HTTPException, status, Request
|
||||
from fastapi.security import APIKeyHeader, OAuth2PasswordBearer
|
||||
from jose import jwt, JWTError
|
||||
from app.config import get_settings
|
||||
|
|
@ -49,7 +49,7 @@ def validate_jwt_token(token: str = Depends(oauth2_scheme)):
|
|||
raise credentials_exception
|
||||
|
||||
|
||||
async def validate_token(token: str = Depends(oauth2_scheme)):
|
||||
async def validate_token(token: str = Depends(oauth2_scheme), request: Request = None):
|
||||
token_data = validate_jwt_token(token)
|
||||
if not token_data:
|
||||
raise HTTPException(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from fastapi import APIRouter, HTTPException, status, Depends
|
||||
from fastapi import APIRouter, HTTPException, status
|
||||
from jose import jwt
|
||||
import datetime
|
||||
from app.config import get_settings
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
from fastapi import FastAPI, Depends
|
||||
from mangum import Mangum
|
||||
from app.portfolio import router as portfolio_router
|
||||
from app.dependencies import validate_api_key, validate_token
|
||||
from app.dependencies import validate_api_key
|
||||
from app.config import get_settings
|
||||
|
||||
|
||||
app = FastAPI(dependencies=[Depends(validate_api_key), Depends(validate_token)])
|
||||
app = FastAPI(dependencies=[Depends(validate_api_key)])
|
||||
|
||||
|
||||
app.include_router(portfolio_router.router)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from fastapi import APIRouter
|
||||
from fastapi import APIRouter, Depends
|
||||
from app.dependencies import validate_token
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/portfolio",
|
||||
tags=["portfolio"],
|
||||
dependencies=[Depends(validate_token)],
|
||||
responses={404: {"description": "Not found"}}
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue