- Home
- Skills
- E-commerce
- Spring Boot 4 + SvelteKit 3 + Keycloak E-shop
Works with the AI Agents you already use
Spring Boot 4 + SvelteKit 3 + Keycloak E-shop
This skill gives your agent a working, end-to-end-tested architecture on the current stack and the fixes for the traps that usually cost days.
$24
Spring Boot 4 + SvelteKit 3 + Keycloak E-shop
Example session with this skill installed
Audit my e-shop (Spring Boot 4 API + SvelteKit 2 frontend + Keycloak, all in Docker Compose). Logged-in users sometimes see an empty cart, and API calls return 401 inside Docker even though login works.
- Read your context and instructions
- Compiled the spring boot 4
Summary
I audited api/ (Spring Boot 4.1) and web/ (SvelteKit 2.x) against the 22-point checklist.
4 security issues explain your two symptoms: users who are logged in look like guests, and the API answers 401 in Docker. 5 other issues are correctness or upgrade problems. I haven't changed any code yet. Pick what to fix below.
Findings
| # | Severity | Evidence | Problem |
|---|---|---|---|
| 1 | 🔴 Critical | web/src/lib/auth.ts:18 grant_type: 'password' | The app collects passwords itself and bypasses Keycloak's brute-force protection and MFA |
| 2 | 🔴 Critical | web/src/lib/keycloak-admin.ts:7 realms/master, admin-cli | Keycloak admin credentials ship in client code. Rotate the admin password now |
| 3 | 🔴 High | web/src/lib/auth.ts:31 localStorage.setItem('access_token'…) | Any XSS can steal tokens |
| 4 | 🟠 High | web/src/hooks.server.ts:9 reads cookies.get('access_token'), but nothing sets it | Your "empty cart" bug. The server always treats users as guests |
| 5 | 🟠 High | api/src/main/resources/application.yml:14 only issuer-uri: http://keycloak:8080/… | Your 401. Browser tokens carry iss=http://localhost:8180, so Spring rejects them with iss claim is not valid |
| 6 | 🟠 Medium | api/pom.xml:52 flyway-core without spring-boot-starter-flyway | Migrations never run on Boot 4. Your dev DB hides this; a fresh volume will fail |
| 7 | 🟡 Medium | CheckoutController.java:41 reads request.getTotal() | The customer can set the price |
| 8 | 🟡 Medium | StockService.java:27 read-modify-write without @Version | Two parallel checkouts can oversell |
| 9 | ⚪ Low | docker-compose.yml:12 postgres:18 + /var/lib/postgresql/data | The container exits on PG 18 |
Proposed fixes
#1–4 together: replace the password grant and admin-API registration with the
BFF flow: Authorization Code + PKCE in web/src/routes/auth/*, httpOnly cookies, jose verification in hooks.server.ts, and Keycloak's own registration page. This works on SvelteKit 2 with renames ($env/dynamic/private, $lib), so you don't have to upgrade to Kit 3 first.
2.
#5: KC_HOSTNAME=http://localhost:8180 + KC_HOSTNAME_BACKCHANNEL_DYNAMIC=true on Keycloak. In Spring: issuer-uri = public URL, jwk-set-uri = internal URL.
3.
#6: add spring-boot-starter-flyway. Your DB already has the tables, so set SPRING_FLYWAY_BASELINE_VERSION=3 once. Otherwise V1 fails with relation already exists.
4.
#7–8: recompute totals server-side from product prices and add an atomic stock update with a CHECK (stock >= 0).
5. #9: mount /var/lib/postgresql.
How I'll verify (isolated, your dev data stays untouched)
docker compose -p shop-verify up -d # own volumes
./mvnw test # Testcontainers, PostgreSQL 18
pnpm check && pnpm build
Then: log in through Keycloak, reload, and check that DevTools shows only httpOnly at/rt/it cookies and an empty localStorage. Add to cart and check out. Log out, then confirm the next login shows the Keycloak form.
Next step: reply with the numbers to fix (I'd start with 1–5), and rotate the Keycloak admin password today regardless.
Connects securely to your tools. The creator never sees your data.
About this skill
Most e-shop starters on Spring Boot + SvelteKit + Keycloak break in the same places: the 401 iss claim is not valid inside Docker, sub missing from tokens, Flyway silently not running, tokens in localStorage. This skill gives your agent a working, end-to-end-tested architecture on the current stack and the fixes for the traps that usually cost days.
Two modes
- New project. Your agent scaffolds the stack from tested assets: Docker Compose, Keycloak realm, Spring Boot 4 backend, SvelteKit 3 frontend with secure login. It verifies each step before moving on.
- Existing project. Your agent runs a 22-point audit, reports findings with
file:lineevidence, and fixes only what you approve. The auth assets also work on SvelteKit 2 with mechanical renames, so you can fix security first and upgrade versions later.
The stack (verified 2026-11-02)
| Layer | Version |
|---|---|
| Java / Spring Boot | 25 LTS / 4.1.2 (Security 7.1, Hibernate 7.4, Jackson 3.1, Flyway 12.4, Testcontainers 2) |
| SvelteKit / Svelte | 3.1 / 5.57 runes, Vite 8, TypeScript 6, Node 26, pnpm 12 |
| Keycloak | 26.8.1 (issuer fix also verified on 25.0.6) |
| PostgreSQL | 18 |
Secure login without tokens in JavaScript
Login runs OIDC Authorization Code + PKCE through a SvelteKit server-side BFF:
- Tokens live only in httpOnly cookies, so XSS can't steal them and
localStoragestays empty. - Keycloak's hosted pages handle login, registration, password policy and brute-force protection. The app never touches passwords.
- Refresh happens automatically. Logout ends the Keycloak session, so SSO doesn't log the user straight back in.
- Forged cookies are rejected. A hand-crafted
alg:nonetoken with anADMINrole was ignored and cleared during testing. - Open redirects are blocked: only same-site return paths and the Keycloak origin are allowed.
- Guest checkout keeps working when a token expires, because the hook drops invalid tokens before Spring would answer 401.
The Spring side is a JWT resource server with realm roles mapped to ROLE_*, an aud=shop-api check, and internal JWKS with a public issuer.
Traps it fixes (and explains)
- Keycloak "invalid issuer" 401 in Docker. It's fixed by
KC_HOSTNAME+KC_HOSTNAME_BACKCHANNEL_DYNAMICand split issuer/JWKS URIs. - Flyway silently not running on Boot 4. Without
spring-boot-starter-flywaythere's no error and no migrations. submissing from tokens. Keycloak 25+ ships it via thebasicscope.- PostgreSQL 18 exits on start with the old
/var/lib/postgresql/datavolume. - SvelteKit 3 changes: config in
vite.config.ts,src/env.ts+$app/env/*,#libimports,$app/state. - Node 25+ has no corepack, and pnpm 12 fails on ignored esbuild builds in Docker.
- Shop domain rules: BigDecimal money, server-side price recomputation, price snapshots, atomic stock reservation, idempotent checkout, customers keyed on
sub.
What's inside
assets/:docker-compose.yml(Postgres + Keycloak + API + web),realm-shop.json,postgres-init.sql,env.exampleassets/backend/: Boot 4pom.xml,SecurityConfig,CurrentUser, a catalog example, FlywayV1__init.sql, Testcontainers config + integration tests, Dockerfileassets/sveltekit/:oidc.ts,hooks.server.ts,/auth/login|register|callback|logout,/api/**proxy, cart with runes + remote functions, Dockerfilereferences/: backend, frontend, Keycloak auth, Docker + Keycloak, and a version matrix with commands to re-check versions before you pin them
Tested, not just written
docker compose up → realm import → PKCE login through the BFF → JWT in Spring → refresh → logout → forged cookie → invalid token. Also tested: 3 Testcontainers integration tests on PostgreSQL 18 and svelte-check with 0 errors.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for E-commerce.
Built for Spring Boot 4.1 + SvelteKit 3 + Keycloak 26 + PostgreSQL 18. SvelteKit 2 works for the auth assets with mechanical renames. Other frameworks (Next.js, Nuxt, Quarkus) aren't covered. Requires Docker for the stack and for Testcontainers. The BFF needs a server runtime (adapter-node); for a static SPA the skill documents the keycloak-js variant and its trade-offs. Versions were verified on 2026-11-02, and the skill includes commands to re-check them.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 13 days ago
- Accounts
Quay
- Software
DockerDocker ComposeJava 25
Maven
Node.js 22.17+pnpm 12Keycloak 26sv
Docker runs the stack and Testcontainers. Node.js 26 LTS is recommended. Keycloak runs in the bundled compose stack.
Permissions
Allowed Hosts
Shell: runs docker compose, mvn, pnpm and curl checks. Files: reads your project for the audit and writes the scaffold or fixes. Network: pulls Docker images/dependencies and calls your local Keycloak and API while verifying. Env vars: client secret, DB and Keycloak admin passwords live in .env, which stays gitignored.