Files
iptv-manager-service/app/routers/auth.py
Stefano 5ee6cb4be4
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m12s
Moved endpoints to routers
2025-05-22 09:34:20 -05:00

22 lines
788 B
Python

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",
)