portal-auth P2(#24 #25):portal_user 模型+認證 API(不 merge,待總管審) #51
Reference in New Issue
Block a user
Delete Branch "portal-auth-p2-users-auth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
範圍(SDD portal-auth tasks.md P2,design §2/§4/§5)
P2=用戶模型+認證 API。不含 P3 UI/P4 admin 頁。console-auth 既有行為零改動。
實作
cypher-executor/src/lib/portal-auth.tspbkdf2-sha256$600000$salt$hash(verify 從儲存值解析 iterations=漸進遷移)、常數時間比對(同 mcp PR#15 實作)。rule 2.1/2.2 界線照 design D-5:UI session 登入=console-auth 同類先例,非 workflow credential 原語,hook 未擋lib/portal-seeds.ts+routes/init-seed.tscreated_by='system';冪等 ensure 掛/init/seed+bootstrap 前自動補。零新表routes/portal.tsowner_id="{CONSOLE_TENANT}::portal"+email head entry O(1) 查找(§2.3)portal_sess:{token}只存 record_id、TTLPORTAL_SESSION_TTL([vars] 預設 604800);每請求回讀 record=停用/改權限即時生效;/portal/session絕不回租戶字串kbdb/src/actions/record-crud.tskbdb/tests/record-grow-owner.test.ts驗收證據表(本機真跑)
npx vitest runnpx vitest runnpx tsc --noEmit--persist-to隔離目錄,demo 8787/8788 未碰)POST /init/seed/portal/admin/users→ 403搜尋隔離實測(design §10 P2 驗收明測)
GET /kbdb/search?q=admin@corp.co(X-Arcrun-API-Key: leo)pbkdf2?q=admin@corp.co&owner_id=leoowner_id=leo::portal同 queryadmin-pass-123pbkdf2-sha256$…)grow-slot 修復證據
owner_id=leo::portal落地,owner-scoped 搜尋命中(修前為孤兒 NULL 搜不到)撞到的問題
[ ] cypher kbdb-proxy 透傳 library(P1 範圍註明順延隨 P3),本 PR 未動(屬 P3 注入路徑,非 P2 範圍)。請總管 review,不自行 merge。 部署屬 gated leo21c wrangler 直推(B 類),不在本 PR。
🤖 Generated with Claude Code
- lib/portal-auth.ts:PBKDF2-SHA256 600k(WebCrypto deriveBits)、pbkdf2-sha256$… 格式、 常數時間比對(UI session 登入,console-auth 同類先例,非 workflow credential 原語) - lib/portal-seeds.ts + init-seed:portal_user / portal_library template 冪等種入(零新表) - routes/portal.ts:login/logout/session/me-password/bootstrap(console owner 閘)/ admin users CRUD + reset-password / 庫目錄 CRUD;帳號資料全寫 {tenant}::portal 子 namespace (D-2)+ email head entry O(1) 查找(§2.3);session KV 只存 record_id、每請求回讀 record → 停用即時生效;絕不回租戶字串;登入節流 5 次/15 分(KV TTL) - [vars] PORTAL_SESSION_TTL(預設 604800)+ types.ts - 順修 kbdb record-crud updateRecord grow-slot 漏 owner_id(design §2.2)+回歸測試 驗證:kbdb 20/20、cypher 133/134(1 失敗 stash 複驗=pre-existing)、雙包 tsc 0; 本機雙 worker 端到端 33/33(含搜尋隔離實測:租戶 ns 搜 email/雜湊 0 筆、對照組 leo::portal 搜得到;明碼落地抽查 0 筆)。console-auth 既有行為未動;demo 8787/8788 未碰。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>