Lộ trình đưa common-iam (stepper) từ "library đầy đủ tính năng" thành "gateway production-ready".
Xem chi tiết grade từng feature ở docs/production-readiness.md.
Nguyên tắc ưu tiên: security-blocking trước, wiring sau, tính năng mới cuối.
Đây là các lỗi khiến gateway hiện tại không an toàn để chạy production. Làm trước tất cả.
- Vá step-up cookie replay bypass —
internal/gateway/guard.go:130-178- Re-evaluate policy trên saved path sau khi rewrite, và chỉ replay khi flow đạt
StateCompleted. - Wire
StateMachine.Complete()/Fail()vào guard (hiện không được gọi).
- Re-evaluate policy trên saved path sau khi rewrite, và chỉ replay khi flow đạt
- DPoP binding thật —
pkg/core/token/dpop.go,claims.go- Thêm
cnf.jktvàoCommonClaims+IntrospectionResponse. - Implement RFC 7638 JWK thumbprint, so với
jktsau introspection; reject nếu lệch. - Bắt buộc
ath(không còn optional). - Thêm replay cache cho
jti(TTL =MaxAge), tái dùngtoken.Cache.
- Thêm
- Vá revocation —
pkg/core/token/revocation.go- JTI revoke: thêm secondary index
jti → tokenHashđể Delete đúng key. RevokeAll: xóa theo prefix per-subject/per-tenant, bỏFlush()toàn cục.
- JTI revoke: thêm secondary index
- Vá
**glob —pkg/core/policy/matcher.go:22-30- Yêu cầu ranh giới:
path == prefix || strings.HasPrefix(path, prefix+"/").
- Yêu cầu ranh giới:
- max_age fail-closed —
pkg/core/policy/engine.go:86-94- Khi
p.MaxAge > 0mà không cóauth_time→ deny (không skip).
- Khi
Exit criteria: security review chạy lại không còn finding Critical/High; test regression cho từng bypass.
Không có cmd/, gateway mode trong README/CLAUDE.md không thể build. Đây là gap "chức năng" lớn nhất.
-
cmd/iam-service/main.go— wiring đầy đủ:- Đọc env (
IAM_ADDR,IAM_REALM,IAM_POLICY_FILE,IAM_UPSTREAM_URL,IAM_OIDC_*,IAM_LOG_FORMAT). - Dev mode tự khởi động LocalAS khi thiếu
IAM_OIDC_DISCOVERY_URL(đúng như README mô tả). - Nối guard + proxy + admin + telemetry + graceful server.
- Đọc env (
-
cmd/iam-cli/main.go— CLI cho policy-check, token-factory, introspect. - Cập nhật
make service/make clichạy được; smoke test trongtests/integration.
Exit criteria: go build ./cmd/... pass; ./iam-service boot ở dev mode; Quickstart trong README reproduce được.
- Audience/issuer enforcement — thêm
audvàoIntrospectionResponse; truyềnjwt.WithIssuer/WithAudience/WithValidMethodsvào JWT validator. - Cross-tenant binding — assert
claims.Issuer == provider.Issuer()sau introspection; documentHeaderResolverchỉ dùng sau trusted edge. - Cache TTL clamp —
min(configuredTTL, time.Until(exp)), không cache khittl <= 0(cảguard.golẫnCachedIntrospector). - Proxy header hygiene — strip
X-Tenant-IDclient gửi, re-injectX-Iam-*từ context đã verify. - Wire FAPI 2.0 —
CommonClaimsimplement interface FAPI; gọifapi.ValidateRequesttừ guard sau introspection, gate bằng config. - CSRF StateID —
saved.StateIDđược sinh trongBeginChallengevà lưu trong cookie ký HMAC. (Việc propagate làm OAuthstatelà client-driven — gateway không tự redirect tới AS; cookie ký + re-evaluate policy khi replay đã chặn CSRF-driven replay.) - Tenant resolve fail-closed — bỏ fallback
"default"ngầm; chỉ opt-in cho single-tenant. - DPoP nonce — server-issued nonce (RFC 9449 §8).
- Nâng coverage
pkg/core/token(56% → ≥80%) — trọng tâm dpop/revocation/cache sau khi vá. - Integration test Redis thật cho
goredis(hiện 0%, chỉ mock). - Authz cho Admin API/UI (hiện chưa có lớp bảo vệ endpoint admin).
- Rate limiting ở guard.
- Benchmark introspection cache-hit path (
BenchmarkCachedIntrospector_CacheHit, ~510ns/op). Load test end-to-end vẫn nên chạy trước release thật. -
token_type_hintcho introspection (RFC 7662 SHOULD). - CI:
make lint+make testgate; publish coverage.
| Milestone | Nội dung | Trạng thái |
|---|---|---|
| M1 | Security blockers | ✅ Hoàn thành |
| M2 | Standalone binaries | ✅ Hoàn thành |
| M3 | Hardening & RFC gaps | ✅ Hoàn thành |
| M4 | Quality & ops | ✅ Hoàn thành |
Library primitives (PKCE, RAR, Token Exchange, providers, middleware, telemetry, devkit) đã production-ready và không nằm trong critical path của các milestone trên.