Client security fixes (cmd/tailscale-tray/main.go): - SSRF protection in Add Server dialog (validateControlURL): reject private/loopback/link-local/cloud-metadata IPs via DNS resolution - RCE gate on AuthURL/BrowseToURL exec paths (validateAuthURL) - Sanitized URL logging (sanitizeURLForLog drops query auth tokens) - Error handling on exec.Command with user-facing showError() Admin panel security (web-admin): - Bcrypt password hashing (replaces SHA256) - Rate limiting: 5 failed logins → 15-min lockout - Session + login attempt cleanup goroutine (hourly) - url.QueryEscape / encodeURIComponent for all API params - Fail-hard startup when no TLS and non-loopback bind - ADMIN_PASSWORD required (no default), password min 12 chars - Username regex whitelist Installer hardening (Setup.wxs): - util:PermissionEx restricts SCM access: only Administrators + SYSTEM can start/stop/reconfigure service. Authenticated Users limited to QueryStatus/QueryConfig/Interrogate - Vital="yes" on ServiceInstall Docs & roadmap: - PRODUCTION_ROADMAP.md: 5-milestone plan (security + features + distribution + ops) with granular tasks, effort, done-when - CLIENT_SECURITY_AUDIT.md, SECURITY_FIXES.md, DEPLOYMENT.md - AI assistant rules (.cursorrules, .antigravityrules, etc.) Build & distribution: - build-msi.ps1, deploy-and-sign.ps1, sign-release.ps1 - redeploy.ps1, tray-deploy.ps1, test-msi.ps1 - installer/msi/ alternative WXS setup - Restored .github/workflows/ removed in mirror cleanup .gitignore hardened: *.pfx, *.p12, *.key, *.pem, .env*
8.4 KiB
description
| description |
|---|
| INS Module feature development workflow. Full lifecycle from planning to verification. Standard for all INS modules (HRM, PRO, CDE, WJC, etc.) |
/ins-develop - INS Module Feature Development
$ARGUMENTS
Architecture Context
All INS modules follow the same architecture:
┌──────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Browser │────▶│ INS.{MOD}.Backend│────▶│ sso-instratech │
│ (Blazor │ │ localhost:{PORT} │gRPC │ 10.0.0.1:8082 │
│ WASM) │ │ │ │ (Auth/SSO) │
└──────────────┘ └────────┬─────────┘ └─────────────────┘
│
┌─────────┴──────────┐
│ │
┌────▼─────┐ ┌──────▼──────┐
│ INS_{MOD}│ │ INS_SYS │
│ Module DB│ │ Auth DB │
└──────────┘ └─────────────┘
| Component | Description |
|---|---|
| Frontend | src/INS.{MOD}.Frontend/ — Blazor WASM, AdminLTE sidebar |
| Backend | src/INS.{MOD}.Backend/ — ASP.NET 8, Kestrel |
| Auth DLL | INS.ModuleControllers.dll — gRPC auth, SSO, navigation |
| Module DB | Business data (employees, projects, documents, etc.) |
| Auth DB | INS_SYS on dev.instratech.net — users, permissions, navigation |
| gRPC | sso-instratech container at 10.0.0.1:8082 |
Phase 0: KNOWLEDGE DISCOVERY (🔴 BẮT BUỘC — Luôn chạy đầu tiên)
KHÔNG ĐƯỢC BỎ QUA. Trước khi làm bất cứ gì, phải tìm kiếm knowledge base.
-
Search knowledge base — Tìm quy tắc dự án, patterns, conventions
mcp_knowledge_search_knowledge(query="{tên tính năng hoặc domain liên quan}") mcp_knowledge_search_knowledge(query="INS component") mcp_knowledge_search_knowledge(query="coding conventions") -
Read relevant KI artifacts — Đọc chi tiết các KI tìm được (architecture, component usage rules, past implementations)
-
Check module-specific knowledge — Tìm theo module
mcp_knowledge_list_modules(solution="ins-pro") // hoặc module đang phát triển mcp_knowledge_get_module_context(solution="...", moduleName="...") -
Check global standards — Đọc coding standards chung
mcp_knowledge_get_global_standards() -
Result: Ghi nhận tất cả rules/constraints phải tuân thủ trước khi code.
Phase 1: RESEARCH (Bắt buộc)
// turbo-all
- Identify module — Determine ModuleCode (e.g.,
INS.HRM,INS.PRO,INS.CDE) - Check DB schema — Connect to module DB and inspect tables
# Query schema $connStr = "<module connection string from appsettings.json>" # SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES # SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '...' - Check existing code — Search for related
.razor,.csfiles, controllers - Check permissions — Query
[Auth].[ApplicationRules]for existing FuncCodes of this module - Check navigation — Verify sidebar entries in module DB (e.g.,
BranchInfotable)
Phase 2: PLAN
-
Create implementation plan — Break into:
- DB changes (tables, seed data, migrations)
- Backend (controllers, services, DTOs)
- Frontend (pages, components, sidebar entries)
- Permissions (new FuncCodes in
INS_SYS) - Navigation (sidebar menu items)
-
Present plan to user — Wait for approval before coding.
Phase 3: IMPLEMENT
3a. Database First
- Create/modify tables — EF Core migrations or raw SQL
- Seed reference data — Insert into module DB
- Add permission rules — Insert into
INS_SYS-- AuthDb connection: Server=dev.instratech.net;Database=INS_SYS;User Id=spm34d.ins;Password=SPM2025@#;... -- 1. Add rule definition INSERT INTO [Auth].[ApplicationRules] (ModuleCode, Category, FuncCode, Description, IsActive, CreatedAt, UpdatedAt) VALUES ('INS.{MOD}', '{Category}', '{MOD}_{CAT}_{ACTION}', N'{Description}', 1, GETDATE(), GETDATE()); -- 2. Assign to root user INSERT INTO [Auth].[UserApplicationRules] (UserId, RuleId, IsAllowed, AssignedBy, AssignedAt) SELECT 'root', ar.Id, 1, 'system', GETDATE() FROM [Auth].[ApplicationRules] ar WHERE ar.FuncCode = '{MOD}_{CAT}_{ACTION}' AND NOT EXISTS (SELECT 1 FROM [Auth].[UserApplicationRules] uar WHERE uar.UserId = 'root' AND uar.RuleId = ar.Id);
3b. Backend
- Create DTOs in
Models/ - Create Controller — follow existing controller patterns in the module
- Register services in
Program.csif needed - Middleware check — ensure new endpoints work with gRPC validation pipeline
3c. Frontend
- Create page in
Pages/— follow existing page patterns - Add sidebar entry — Insert navigation record (e.g.,
BranchInfo) - Use INS components —
INS_DataGrid,INS_Popup,INS_RuleInit(check KB!) - Wire API calls —
HttpClientwith auth token fromIModuleAuthenticationService
Phase 4: BUILD & TEST
// turbo-all
-
Stop server
Stop-Process -Name "INS.{MOD}.Backend" -Force -ErrorAction SilentlyContinue -
Build
dotnet build src/INS.{MOD}.Backend/INS.{MOD}.Backend.csproj -
Fix build errors — Check
error CSoutput, fix, rebuild -
Start server
dotnet run --project src/INS.{MOD}.Backend/INS.{MOD}.Backend.csproj -
Verify startup logs — Must see:
Now listening on: http://localhost:{PORT}✅- No gRPC connection errors ✅
- No DB errors ✅
Phase 5: VERIFY
-
API test via PowerShell
$login = Invoke-RestMethod -Method Post -Uri "http://localhost:{PORT}/api/auth/login" ` -Body (@{email="root@local.instratech";password="admin123"} | ConvertTo-Json) -ContentType "application/json" $h = @{ "Authorization" = "Bearer $($login.token)" } Invoke-RestMethod -Uri "http://localhost:{PORT}/{mod}/api/{endpoint}" -Headers $h -
Browser test — Login, navigate, verify:
- All buttons visible (permissions loaded correctly)
- Data displays, CRUD works
- Popup/modal margins follow INS component guidelines
-
Permission verify —
api/applicationrule/userreturns new FuncCodes
Phase 6: REVIEW
- Check logs for warnings/errors
- Remove debug code
- Report to user with change summary
Troubleshooting
| Symptom | Root Cause | Fix |
|---|---|---|
| gRPC connection refused | sso-instratech stopped |
ssh root@36.50.176.30 "docker start sso-instratech" |
| 401 on data API | Token not validated by gRPC | Check GrpcTokenValidationMiddleware logs |
401 on /api/applicationrule |
Path not bypassed | UseWhen must exclude /api/applicationrule |
| Buttons missing | FuncCode not in DB | Insert into [Auth].[ApplicationRules] + assign to user |
| DB already exists | EnsureCreated() |
Wrap in try-catch |
| Build locked file | Previous process | Stop-Process -Name "INS.{MOD}.Backend" -Force |
| SSO register-session fail | gRPC server unreachable | Check appsettings.json > GrpcClient.ServerUrl |
| Popup margins wrong | Component misuse | Check knowledge base for INS component rules |
Server Infrastructure
| Container | Host Port | Internal | Purpose |
|---|---|---|---|
sso-instratech |
8082 | 8082 | SSO/Auth gRPC (ALL modules use this) |
ins-sys |
8083/7001 | 8082/8080 | INS.SYS Backend |
epm-sqlserver |
1434 | 1433 | SQL Server |
epm-gateway |
5000 | 5000 | API Gateway |
SSH: ssh root@36.50.176.30
Examples
/ins-develop thêm module quản lý hợp đồng
/ins-develop thêm chức năng export PDF cho báo cáo
/ins-develop thêm trang dashboard thống kê
/ins-develop thêm CRUD cho bảng mới