23 lines
785 B
Python
23 lines
785 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",
|
|
)
|