Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Spring Boot 4 + SvelteKit 3 + Keycloak E-shop

    1

    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

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Spring Boot 4 + SvelteKit 3 + Keycloak E-shop

    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

    #SeverityEvidenceProblem
    1🔴 Criticalweb/src/lib/auth.ts:18 grant_type: 'password'The app collects passwords itself and bypasses Keycloak's brute-force protection and MFA
    2🔴 Criticalweb/src/lib/keycloak-admin.ts:7 realms/master, admin-cliKeycloak admin credentials ship in client code. Rotate the admin password now
    3🔴 Highweb/src/lib/auth.ts:31 localStorage.setItem('access_token'…)Any XSS can steal tokens
    4🟠 Highweb/src/hooks.server.ts:9 reads cookies.get('access_token'), but nothing sets itYour "empty cart" bug. The server always treats users as guests
    5🟠 Highapi/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🟠 Mediumapi/pom.xml:52 flyway-core without spring-boot-starter-flywayMigrations never run on Boot 4. Your dev DB hides this; a fresh volume will fail
    7🟡 MediumCheckoutController.java:41 reads request.getTotal()The customer can set the price
    8🟡 MediumStockService.java:27 read-modify-write without @VersionTwo parallel checkouts can oversell
    9⚪ Lowdocker-compose.yml:12 postgres:18 + /var/lib/postgresql/dataThe 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:line evidence, 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)

    LayerVersion
    Java / Spring Boot25 LTS / 4.1.2 (Security 7.1, Hibernate 7.4, Jackson 3.1, Flyway 12.4, Testcontainers 2)
    SvelteKit / Svelte3.1 / 5.57 runes, Vite 8, TypeScript 6, Node 26, pnpm 12
    Keycloak26.8.1 (issuer fix also verified on 25.0.6)
    PostgreSQL18

    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 localStorage stays 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:none token with an ADMIN role 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_DYNAMIC and split issuer/JWKS URIs.
    • Flyway silently not running on Boot 4. Without spring-boot-starter-flyway there's no error and no migrations.
    • sub missing from tokens. Keycloak 25+ ships it via the basic scope.
    • PostgreSQL 18 exits on start with the old /var/lib/postgresql/data volume.
    • SvelteKit 3 changes: config in vite.config.ts, src/env.ts + $app/env/*, #lib imports, $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.example
    • assets/backend/: Boot 4 pom.xml, SecurityConfig, CurrentUser, a catalog example, Flyway V1__init.sql, Testcontainers config + integration tests, Dockerfile
    • assets/sveltekit/: oidc.ts, hooks.server.ts, /auth/login|register|callback|logout, /api/** proxy, cart with runes + remote functions, Dockerfile
    • references/: 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.

    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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    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

    Requires

    Maven
    Quay
    Docker
    Docker Compose
    Java 25
    Node.js 22.17+
    pnpm 12
    Keycloak 26
    sv
    Node.js

    Permissions

    Terminal / Shell
    Network Access
    Read Files
    Write Files
    Environment Variables

    Allowed Hosts

    repo1.maven.org
    quay.io

    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.

    Listed13 days ago

    What's inside

    Frequently Asked Questions

    The 401 'iss claim is not valid' happens because the browser reaches Keycloak on localhost while the API reaches it on the Docker network, so the issuer differs. The skill pins it with KC_HOSTNAME + KC_HOSTNAME_BACKCHANNEL_DYNAMIC on Keycloak and splits Spring's config: issuer-uri points to the public URL, jwk-set-uri to the internal one. The fix was verified end-to-end on Keycloak 26.8.1 and 25.0.6.

    The SKILL.md workflow (scaffold and audit modes), five reference guides (backend, frontend, Keycloak auth, Docker + Keycloak, version matrix) and tested assets: docker-compose.yml, a Keycloak realm export, Postgres init, a Spring Boot 4 backend skeleton with security config, Flyway migration and Testcontainers tests, and the SvelteKit 3 BFF auth routes, hooks, API proxy and cart.

    Yes. In audit mode your agent checks 22 known problems (password grant, admin credentials in client code, tokens in localStorage, missing Flyway starter, client-supplied prices, overselling, over-broad CORS and more). It reports each one with file:line evidence and changes only what you approve. It verifies on an isolated compose project, so your dev data isn't touched.

    Java 25, Docker, Node.js 22.17+ (26 LTS recommended) and pnpm 12. The skill targets Spring Boot 4.1.2, SvelteKit 3.1 / Svelte 5, Keycloak 26.8.1 and PostgreSQL 18, verified on 2026-11-02. If you're on SvelteKit 2, the auth assets work with mechanical renames, so you can fix security before upgrading.

    Any agent that supports the SKILL.md standard and can read and write files and run shell commands: Claude Code, Codex CLI, Cursor, Gemini CLI, VS Code Copilot and others. Scaffolding and auditing touch many files, so an agent with file access and a terminal works best.

    New in E-commerce