Migrate pal-e-app auth + data fetching to client-side #52
Labels
No labels
domain:backend
domain:devops
domain:frontend
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-docs-app#52
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Type
Feature
Lineage
Depends on
forgejo_admin/pal-e-app#51(convention-sveltekit-spa must exist first as the spec).Repo
forgejo_admin/pal-e-appUser Story
As pal-e-app
I want to authenticate via keycloak-js + PKCE and fetch data client-side with Bearer tokens
So that I have no server secrets and work as a true SPA
Context
pal-e-app currently uses Auth.js with server-side Keycloak OIDC sessions and loads all data via +page.server.ts files. The platform SvelteKit convention (Phase 29) requires keycloak-js + PKCE for client-side auth and client-side fetch() with Bearer tokens. mcd-tracker-app already implements this pattern successfully. This migration is a prerequisite for switching to adapter-static (issue #53).
The app currently uses TypeScript with typed API responses via
src/lib/api.ts. The replacement client-side API module should remain TypeScript (api-client.ts) to preserve the type system.Keycloak client
pal-e-appshould be created in thepal-erealm (matching existing platform apps) as a public client with PKCE. Current code references themasterrealm — this must change.File Targets
Files to create:
src/lib/keycloak.ts— keycloak-js OIDC wrapper (model on ~/mcd-tracker-app/src/lib/keycloak.js, but in TypeScript)src/lib/api-client.ts— client-side fetch with Bearer token (model on ~/mcd-tracker-app/src/lib/api.js, but in TypeScript preserving existing type interfaces)Files to modify:
src/routes/+layout.svelte— add keycloak init + auth guard, remove Auth.js session referencessrc/routes/+page.svelte— client-side data loading instead of server data propsrc/routes/boards/+page.svelte— client-side data loadingsrc/routes/boards/[slug]/+page.svelte— client-side data loadingsrc/routes/notes/+page.svelte— client-side data loadingsrc/routes/notes/[slug]/+page.svelte— client-side data loadingsrc/routes/notes/[slug]/edit/+page.svelte— client-side data loading (if kept) or removesrc/routes/projects/+page.svelte— client-side data loadingsrc/routes/projects/[slug]/+page.svelte— client-side data loadingsrc/routes/repos/+page.svelte— client-side data loadingsrc/routes/search/+page.svelte— client-side data loadingsrc/routes/dashboard/+page.svelte— client-side data loadingsrc/routes/tags/+page.svelte— client-side data loadingsrc/routes/tags/[name]/+page.svelte— client-side data loading (if exists)src/lib/components/QuickJot.svelte— update to use client-side API + auth tokensrc/lib/slugCache.ts— update or remove if it depends on server-side importspackage.json— remove @auth/sveltekit and Auth.js deps, add keycloak-jsFiles to remove:
src/auth.ts— Auth.js configurationsrc/hooks.server.ts— Auth.js server hookssrc/routes/+layout.server.ts— server-side session loadingsrc/routes/+page.server.ts— server-side data loadingsrc/routes/boards/+page.server.tssrc/routes/boards/[slug]/+page.server.tssrc/routes/notes/+page.server.tssrc/routes/notes/[slug]/+page.server.tssrc/routes/notes/[slug]/edit/+page.server.ts(if exists)src/routes/projects/+page.server.tssrc/routes/projects/[slug]/+page.server.tssrc/routes/repos/+page.server.tssrc/routes/search/+page.server.tssrc/routes/dashboard/+page.server.tssrc/routes/tags/+page.server.tssrc/routes/tags/[name]/+page.server.ts(if exists)src/routes/signin/— entire directorysrc/routes/signout/— entire directorysrc/routes/api/— entire directory (proxy routes no longer needed)src/lib/api.ts— server-side API client (replaced by api-client.ts)Files the agent should NOT touch:
svelte.config.js— adapter switch is issue #53Dockerfile— Dockerfile switch is issue #53k8s/— k8s changes are issue #53Acceptance Criteria
pal-e-appcreated inpal-erealm (public client, PKCE)Test Expectations
npm run checkpasses (no type errors)npm run test:e2e && npm run checkConstraints
~/mcd-tracker-app/src/lib/keycloak.js— proven pattern~/mcd-tracker-app/src/lib/api.js— proven patternpal-erealm (notmaster)Checklist
Related
forgejo_admin/pal-e-app#51— convention must exist firstforgejo_admin/pal-e-app#53— depends on this ticketproject-pal-e-docs— pal-e-app is the frontend for this projectconvention-sveltekit-spa— the spec this followsScope Review: NEEDS_REFINEMENT
Review note:
review-413-2026-03-26File targets are incomplete -- 6 files missing from scope (auth.ts, hooks.server.ts, notes/[slug]/edit/, tags/[name]/, QuickJot.svelte, slugCache.ts). Dependency #51 (convention-sveltekit-spa) is still open and the convention note does not exist yet.
Must fix before READY:
src/auth.tsandsrc/hooks.server.tsto "Files to remove"src/routes/notes/[slug]/edit/andsrc/routes/tags/[name]/to both modify and remove listssrc/lib/components/QuickJot.svelteto "Files to modify" (uses/api/notesproxy being removed)src/lib/slugCache.tsto "Files to modify" (imports from$lib/apibeing removed)$lib/api)masterin current code vspal-ein issue) and client creation method$env/dynamic/privateimports remain; type imports resolvestory:Xlabel to board item #413VITE_env var naming for client-side API URLClosing — work completed and merged. Board item confirmed
done.