Use caseIdentity
Logout
Use case POST /api/auth/logout của Go Identity Service.
Use case: Logout
Trạng thái
Code-confirmed. Chưa checkpoint-closed trong batch Go Gateway + Go Identity.
Service sở hữu
Identity Service.
API Gateway hiện xem route này là public route.
Endpoint
| Method | Path |
|---|---|
POST | /api/auth/logout |
Yêu cầu xác thực
Optional.
Identity cố identify session từ:
Authorization: Bearer ...- body JSON field
refreshToken - refresh
HttpOnly cookie
Mục tiêu
Kết thúc session nếu identify được, clear refresh cookie, trả logout success.
Luồng request
Client
→ API Gateway
→ Identity Service
→ Database / token service
→ ResponseContract API
Request
Body có thể rỗng.
{
"refreshToken": "refreshToken"
}Success response
{
"success": true,
"code": "AUTH_LOGOUT_SUCCESS",
"data": {
"message": "Đăng xuất thành công."
}
}Error response
MALFORMED_JSON: body không parse được.VALIDATION_ERROR: body córefreshTokennhưng blank.- TODO: error DB/infra path chưa được document chi tiết.
Hành vi database
Read:
identity.auth_session: identify session nếu token hợp lệ.identity.account: validate account status khi identify token.
Write:
identity.auth_session: nếu tìm được session chưa revoked, setstatus = 'REVOKED', setrevoked_at.
Hành vi token/session
- Access token hoặc
refreshTokenđều có thể dùng để identify session. - Nếu không identify được session, use case vẫn trả success.
- Response clear refresh
HttpOnly cookie. - README ghi compatibility note: no-token logout trả
200 AUTH_LOGOUT_SUCCESS.
Logs và observability
- Gateway access log có
route_id=identity-authnếu đi qua Gateway. - Identity log có
path=/api/auth/logout. - Không log
Authorization, cookie,Set-Cookiehoặc token values.
Tiêu chí nghiệm thu
- Happy path pass.
- Error path pass.
- Logs có request/correlation id nếu đi qua Gateway.
- Bruno/local smoke test pass nếu có.
TODO
- Chưa đóng: checkpoint chính cho logout qua Gateway/frontend.