IDOR filter ContractsController:
- ListContractsQueryHandler + ICurrentUser: non-admin chi thay HD minh la Drafter hoac role eligible phase hien tai
- GetContractQueryHandler + ICurrentUser: throw ForbiddenException neu truy cap HD khong lien quan
- GetEligiblePhases() internal static trong ListContractsQueryHandler — mirror GetMyInboxQueryHandler.PhaseActorRoles (Drafter/DeptManager → DangSoanThao/DangDamPhan/DangInKy, ProjectManager+PRO+CCM+FIN+ACT+EQU → DangGopY, CostControl → DangKiemTraCCM, Director+AuthorizedSigner → DangTrinhKy, HrAdmin → DangDongDau)
SLA Expiry BackgroundService (Phase 3 iteration 2 partial):
- Infrastructure/HostedServices/SlaExpiryJob MOI: BackgroundService moi 15 phut (delay 30s startup)
- Query Contracts WHERE SlaDeadline < UtcNow AND Phase NOT IN (DaPhatHanh, TuChoi)
- Map phase → next (happy path). Goi IContractWorkflowService.TransitionAsync voi actorUserId=null + Decision=AutoApprove + comment 'AUTO: het SLA phase X (Nh qua han)'
- Try-catch tung contract, 1 fail khong block batch
- Log structured: 'SlaExpiryJob: auto-approved contract {Id} {From} → {To}'
- Package Microsoft.Extensions.Hosting added to Infrastructure
- DI register AddHostedService<SlaExpiryJob>
Admin password warning (Phase 5.1):
- DbInitializer.WarnDefaultAdminPasswordAsync: check CheckPasswordAsync voi AdminPassword default → log WRN '⚠️ Admin user vẫn dùng password mặc định. ĐỔI NGAY trong production!'
- Chain vao InitializeAsync sau cac seed
E2E verified:
- Admin GET /contracts → total 1 (see all)
- Drafter GET /contracts → total 0 (IDOR filter, chua tao HD nao)
- API startup log: '⚠️ Admin user admin@solutionerp.local vẫn dùng password mặc định'
- Build + TS check → pass
Docs:
- STATUS.md: Phase 5.1 hau nhu xong (IDOR + admin warning + SLA job tick), cumulative BE 3900 LOC
- migration-todos.md: tick Phase 5.1 IDOR + admin warning, Phase 3 iter 2 SlaExpiryJob + E2E non-admin + admin warning
- session log 2026-04-21-1730-idor-sla-job.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5.9 KiB
5.9 KiB
STATUS — Snapshot hiện tại
Update rule: trước khi bắt đầu 1 task → ghi row vào
🔥 In Progress. Xong → chuyển sang✅ Recently Done.
Last updated: 2026-04-21 17:30
📍 Phase hiện tại: IDOR + SLA Job xong — gần đủ feature, chờ Gitea URL cho Phase 5 deploy prod
🔥 In Progress
(không có)
✅ Recently Done (newest on top)
| Ngày | Ai | Task | Commit |
|---|---|---|---|
| 2026-04-21 | Claude | IDOR + SLA Job + Admin warning — ContractsController List/GetDetail filter theo role (non-admin chỉ thấy HĐ mình là Drafter hoặc role eligible phase). SlaExpiryJob BackgroundService auto-approve quá hạn mỗi 15min với Decision=AutoApprove. DbInitializer warn log khi admin vẫn dùng password default | (sắp commit) |
| 2026-04-21 | Claude | Phase 5.1 Security + Users Mgmt — Security headers + Identity lockout + LoginHandler check + Users CQRS + UsersController + FE /system/users |
11e61c9 |
| 2026-04-21 | Claude | Phase 5 Prep — BE rate limit + health check + Serilog file + HSTS + scripts deploy-iis/backup-sql + .gitea/workflows/deploy.yml + 4 guides + FE refresh token queue pattern | 46a2cab |
| 2026-04-21 | Claude | Phase 4 Report MVP + Docs Consolidation — Dashboard KPI + Excel export + rules.md + architecture.md + schema-diagram.md + gotchas update 26 pitfalls | fe7ad8e |
| 2026-04-21 | Claude | Phase 3 Workflow MVP — 9 phase state machine + gen mã HĐ RG-001 | 7e957a7 |
| 2026-04-21 | Claude | Phase 2 Form Engine MVP | 5113e4c |
| 2026-04-21 | Claude | Phase 1.2 — CRUD Master + Permission Matrix | 54d6c9b |
| 2026-04-21 | Claude | Docs addition | 49a5f57 |
| 2026-04-21 | Claude | Phase 1 foundation | 702411f |
| 2026-04-21 | Claude | Phase 0 | 25dad7f |
Session logs: P0 · P1f · P1.2 · P2 · P3 · P4 · P5prep
Docs entry points:
rules.md·architecture.md·HANDOFF.mdworkflow-contract.md·forms-spec.mddatabase/database-guide.md·database/schema-diagram.mdflows/(7 file) ·guides/(4 file) ·gotchas.mdchangelog/migration-todos.md·changelog/sessions/(7 file)
🎯 Next up
Phase 5 còn lại (cần Gitea URL)
- Setup Gitea remote + push all commits
- Enable Gitea Actions runner (Windows + Ubuntu)
- Set 5 secrets trong Gitea (IIS_HOST/USER/PASSWORD/JWT_SECRET/DB_CONNECTION)
- Test CI/CD workflow lần đầu trên staging
- Windows Server setup IIS theo
guides/deployment-iis.md - HTTPS cert (win-acme Let's Encrypt)
- SQL Server prod + Task Scheduler backup
- Smoke test end-to-end prod
- UAT 1 tuần 2-3 user thật
Phase 5.1 Security — hầu như xong
- Security headers middleware (X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy, CSP)
- Identity account lockout (5 fail → 15min, config-driven)
- Password policy config-driven
- LoginHandler check lockout + AccessFailedAsync + reset on success
- BE Users management + FE admin UsersPage
- IDOR check ContractsController (non-admin chỉ thấy HĐ mình/role eligible)
- Admin password warning log startup
- SLA Expiry BackgroundService auto-approve
- Dependencies scan CI (
dotnet list package --vulnerable+npm audit) - Roles CRUD — optional
Polish iterations
Phase 2 iter 2: convert .doc, field spec JSON + form builder, {{#loop}}, PDF convert Phase 3 iter 2: SLA job auto-approve, email/in-app notify, attachment upload, RowVersion Phase 4 iter 2: SLA overdue report, PDF HĐ export, dashboard user-specific
Quick wins
- FE Users management + Roles CRUD (test permission non-admin)
- Filter Inbox theo phase FE
- Test refresh token flow manual (logout/login flow)
📊 Thông số cumulative
| P0 | P1f | P1.2 | P2 | P3 | P4 | P5 prep | |
|---|---|---|---|---|---|---|---|
| BE LOC | 0 | ~400 | ~1500 | ~1900 | ~2700 | ~3100 | ~3300 |
| DB tables | 0 | 7 | 12 | 14 | 19 | 19 | 19 |
| API endpoints | 0 | 4 | 20 | 23 | 31 | 33 | 35 (+health) |
| Migrations | 0 | 1 | 3 | 4 | 5 | 5 | 5 |
| FE pages | 0 | 2 | 6 | 7 | 14 | 16 | 16 |
| Scripts PS | 0 | 0 | 0 | 1 (convert-doc) | 1 | 1 | 3 (+deploy-iis, backup-sql) |
| CI/CD workflow | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| Docs | 10 | 13 | 14 | 24 | 26 | 30 | 35 (+4 guides + session log) |
| Commits | 1 | 2 | 3 | 5 | 6 | 7 | 8 (sắp) |
🚨 Blockers / risks
- ⏳ Gitea remote URL — ĐANG CẦN để push + setup CI/CD
- ⚠️ Phase 5.1 security hardening chưa làm (headers, account lockout, IDOR check)
- ⚠️ 3 file .doc chưa convert (Phase 2 carryover)
- ⚠️ SLA không tự auto-approve (Phase 3.2)
- ⚠️ Email/in-app notification chưa có
- ⚠️ FE Users management chưa có — khó test permission non-admin
- ⚠️ Rate limit global 300/min/IP — OK cho dev, cần tăng cho prod nếu nhiều user
Credentials + URLs
admin@solutionerp.local / Admin@123456
- API: http://localhost:5443 — Swagger
/swagger(dev only) — Health/health/live+/health/ready - Admin FE: http://localhost:8082 —
/dashboard,/contracts,/reports,/master/*,/forms,/system/permissions - User FE: http://localhost:8080 —
/inbox,/contracts/new,/my-contracts