15 lines
612 B
Python
15 lines
612 B
Python
from fastapi import APIRouter, status
|
|||
|
|
|
||
|
|
from app.api.schemas.visitor_tokens import VisitorTokenResponse
|
||
|
|
from app.core.config import get_settings
|
||
|
|
from app.core.security import VisitorTokenIssuer
|
||
|
|
|
||
|
|
router = APIRouter(prefix="/api/v1/visitor-tokens", tags=["visitor-tokens"])
|
||
|
|
|
||
|
|
|
||
|
|
@router.post("", response_model=VisitorTokenResponse, status_code=status.HTTP_201_CREATED)
|
||
|
|
async def issue_visitor_token() -> VisitorTokenResponse:
|
||
|
|
settings = get_settings()
|
||
|
|
token, _expires_at = VisitorTokenIssuer(settings).issue()
|
||
|
|
return VisitorTokenResponse(access_token=token, expires_in=settings.visitor_token_ttl_seconds)
|