feat(kb): serve portal KB feed only via the portal-authed route #118
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/portal-kb-feed-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?
Follow-up: "portal KB feed needs portal-JWT auth."
Finding
Two routes served portal-visible articles:
GET /api/v1/portal/kb(list_kb) - already behind PortalAuthMiddleware + RequirePortalAuth, scoped to the authenticated contact tenant_id/company_id. This is what the mokosh-apps portal page actually calls.GET /kb/articles/portal- mislabeled "portal" but ran under agent auth (RequireKnowledgeBase), scoped to the agent tenant, NOT portal-JWT protected, and consumed by nothing (verified across server + mokosh-apps).Change
Remove the redundant, unauthed-for-portal
/kb/articles/portalroute and its now-deadKbService::list_portal_articles. The portal-visible feed is served exclusively by the portal-authenticated/api/v1/portal/kb, scoped from JWT claims (published + public/client-specific for the contact company). No mokosh-apps change needed (client already uses the surviving path).Test (
tests/knowledge_base.rs, #[sqlx::test], through the real router): no/garbage token -> 401; valid portal token -> only that tenant+company published portal-visible articles (excludes drafts, other-company client_specific, other-tenant public).Confirm
Removed rather than retrofitted the agent-tree route (a RequirePortalAuth extractor there would always 401, since PortalAuthState is only populated under the portal tree). If a staff-facing preview of portal-visible articles is wanted, reintroduce under agent auth with a non-portal name. Needs a gate run.