My App
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

MethodPath
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
→ Response

Contract 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ó refreshToken như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, set status = 'REVOKED', set revoked_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-auth nếu đi qua Gateway.
  • Identity log có path=/api/auth/logout.
  • Không log Authorization, cookie, Set-Cookie hoặ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.

On this page