refactorisation pour correction de sécurité
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
This commit is contained in:
+10
-1
@@ -5,8 +5,10 @@ Routes API pour l'authentification JWT.
|
||||
from datetime import datetime, timezone
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||
from fastapi.security import OAuth2PasswordRequestForm
|
||||
from slowapi import Limiter
|
||||
from slowapi.util import get_remote_address
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.dependencies import get_db, get_current_user, get_current_user_optional
|
||||
@@ -17,6 +19,7 @@ from app.schemas.auth import (
|
||||
from app.services import auth_service
|
||||
|
||||
router = APIRouter()
|
||||
limiter = Limiter(key_func=get_remote_address)
|
||||
|
||||
|
||||
@router.get("/status")
|
||||
@@ -55,7 +58,9 @@ async def auth_status(
|
||||
|
||||
|
||||
@router.post("/setup")
|
||||
@limiter.limit("3/minute")
|
||||
async def setup_admin(
|
||||
request: Request,
|
||||
user_data: UserCreate,
|
||||
db_session: AsyncSession = Depends(get_db)
|
||||
):
|
||||
@@ -93,7 +98,9 @@ async def setup_admin(
|
||||
|
||||
|
||||
@router.post("/login", response_model=Token)
|
||||
@limiter.limit("5/minute")
|
||||
async def login_form(
|
||||
request: Request,
|
||||
form_data: OAuth2PasswordRequestForm = Depends(),
|
||||
db_session: AsyncSession = Depends(get_db)
|
||||
):
|
||||
@@ -129,7 +136,9 @@ async def login_form(
|
||||
|
||||
|
||||
@router.post("/login/json", response_model=Token)
|
||||
@limiter.limit("5/minute")
|
||||
async def login_json(
|
||||
request: Request,
|
||||
credentials: LoginRequest,
|
||||
db_session: AsyncSession = Depends(get_db)
|
||||
):
|
||||
|
||||
+147
-1085
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user