My App
Checkpoint

Go Gateway và Identity đã đóng

Checkpoint kỹ thuật ngày 2026-06-25 cho Go API Gateway và Go Identity Service.

Go Gateway và Identity đã đóng

Mục tiêu

Ghi lại checkpoint ngày 2026-06-25: Go API Gateway và Go Identity Service đã đóng cho local compose, frontend auth và select-branch.

Trạng thái hiện tại

Đã đóng:

  • API Gateway repo/folder: api-gateway
  • Gateway container: centeros-api-gateway
  • Gateway image: dorrissdang/centeros-api-gateway:main
  • Gateway port: 8080
  • Identity Service repo/folder: identity-service
  • Identity container: centeros-identity-service
  • Identity image: dorrissdang/centeros-identity-service:main
  • Identity port: 8081

Java Gateway và Java Identity là legacy/đã xóa, không phải runtime hiện tại.

Validated Gateway behavior:

  • GET /healthz
  • POST /api/auth/login
  • POST /api/auth/refresh
  • POST /api/auth/select-branch
  • GET /api/workspaces/current-context route được tới Entitlement Service, nhưng Entitlement Service chưa đóng.
  • CORS preflight được xử lý local tại Gateway, OPTIONS trả 204.

Validated Identity behavior:

  • GET /healthz
  • GET /.well-known/jwks.json
  • POST /api/auth/login
  • POST /api/auth/refresh
  • POST /api/auth/select-branch

Frontend validation:

  • Login works.
  • Refresh works after valid session.
  • Manager multi-branch login works.
  • Select branch works.
  • First stale/missing /api/auth/refresh trả 401 là acceptable nếu login/refresh sau đó thành công.

Luồng chính

Frontend
→ Go API Gateway
→ Go Identity Service
→ PostgreSQL

Manager multi-branch
→ POST /api/auth/login
→ accountAccessToken + branches[]
→ POST /api/auth/select-branch
→ branch-scoped accessToken

Quy tắc quan trọng

Token roles:

  • accountAccessToken: account-scoped token dùng cho select/switch branch.
  • accessToken: branch-scoped token dùng cho business APIs sau khi branch context đã chọn.
  • refreshToken: session rotation token, cũng được set làm HttpOnly cookie khi applicable.

Gateway trusted headers sau branch token:

  • X-Account-Id
  • X-Workspace-Id
  • X-Member-Id
  • X-Active-Branch-Id
  • X-Branch-Ids
  • X-Roles
  • X-Token-Scope=BRANCH
  • X-Request-Id
  • X-Correlation-Id

Downstream services như Entitlement Service nên consume Gateway trusted headers. Downstream services không nên verify client JWT trong normal internal runtime.

Liên quan

TODO

Remaining work cho Entitlement Service:

  1. Direct Entitlement Bruno regression.
  2. Entitlement + Payment Java billing-context integration.
  3. Gateway -> Entitlement E2E.
  4. Validate Flow 3 / 4A / 4B.
  5. Connect FE setup/current-context fully.

On this page