Moved endpoints to routers
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m12s

This commit is contained in:
2025-05-22 09:34:20 -05:00
parent c1e3a6ef26
commit 5ee6cb4be4
5 changed files with 138 additions and 124 deletions

22
app/routers/auth.py Normal file
View File

@@ -0,0 +1,22 @@
from fastapi import APIRouter
from app.auth.cognito import initiate_auth
from app.models.auth import SigninRequest, TokenResponse
router = APIRouter(
prefix="/auth",
tags=["authentication"]
)
@router.post("/signin", response_model=TokenResponse, summary="Signin Endpoint")
def signin(credentials: SigninRequest):
"""
Sign-in endpoint to authenticate the user with AWS Cognito using username and password.
On success, returns JWT tokens (access_token, id_token, refresh_token).
"""
auth_result = initiate_auth(credentials.username, credentials.password)
return TokenResponse(
access_token=auth_result["AccessToken"],
id_token=auth_result["IdToken"],
refresh_token=auth_result.get("RefreshToken"),
token_type="Bearer",
)