Skip to content

Enforce backend authentication, add /health, drift guardrail, and lint gate - #10

Merged
oblomov-dev merged 2 commits into
mainfrom
claude/cap2ui5-project-analysis-w8c8fw
Jul 26, 2026
Merged

Enforce backend authentication, add /health, drift guardrail, and lint gate#10
oblomov-dev merged 2 commits into
mainfrom
claude/cap2ui5-project-analysis-w8c8fw

Conversation

@oblomov-dev

Copy link
Copy Markdown
Member

Security, deployment, and CI hardening for the CAP app skeleton.

Security (headline: the backend was publicly reachable)

  • Remove "[production]": { "auth": false } — production now uses xsuaa; development uses a mocked user so the suite stays runnable.
  • @(requires: 'authenticated-user') on both rootService (the z2ui5 roundtrip action) and AdminService (the draft table + Northwind proxy) — the serialized-state draft table is no longer anonymously readable and the mutating roundtrip is no longer anonymously callable. In BTP the approuter authenticates via xsuaa and forwards the JWT.
  • xs-security.json: add a User scope + role template (was empty).
  • Auth boundary documented in server.js: the GET/HEAD routes serve only the static shell + CSRF ack and are intentionally public.

Deployment & CI

  • Implement GET /healthmta.yaml declared it as the CF readiness endpoint but nothing served it.
  • update_cap.yml: commit the refreshed core mirror only after assemble + the app's jest suite pass, so a broken upstream core can't land on main permanently.
  • assemble-cap.js drift guardrail: fail the build with an actionable message when the mirrored core's dependencies diverge from the frozen core lock entry (the biggest latent break); also guard the pre-merge lockfile parse.

Tooling

  • ESLint flat config + CI lint gate.
  • Dependabot now watches the npm ecosystem in /src (the app lock was untended).

Tests

Starter/Northwind updated to authenticate; new case asserts the roundtrip and the draft table reject unauthenticated access (401). New guardrail test covers the core-lock drift case. App suite (18) + builder suite (13) green.

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits July 26, 2026 15:52
…t on tests

Security (priority-1 finding: the backend was publicly reachable):
- package.json: drop the "[production]": { auth: false } override that
  disabled CAP's auth middleware in production; production now uses xsuaa,
  development uses a mocked user so the suite stays runnable.
- z2ui5-service.cds: @(requires: 'authenticated-user') on both rootService
  (the z2ui5 roundtrip action) and AdminService (the draft table + Northwind
  proxy) — the serialized-state draft table is no longer anonymously
  readable, and the mutating roundtrip is no longer anonymously callable. In
  BTP the approuter authenticates via xsuaa and forwards the JWT
  (HTML5.ForwardAuthToken), so the roundtrip still runs under the real user.
- xs-security.json: add a User scope + role template (was empty).

Deployment:
- server.js: implement GET /health (public, cheap 200) — mta.yaml already
  declares it as the CF readiness-check endpoint but nothing served it.

CI:
- update_cap.yml: commit the refreshed run/input/core mirror only AFTER
  assemble + the app's jest suite pass, so a broken upstream core can no
  longer land on main permanently while the publish is (correctly) gated.

Tests: starter/northwind updated to authenticate; new starter case asserts
the roundtrip and the draft table reject unauthenticated access (401).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018FTxX214GdPJZXvz88Mbq8
…docs

- assemble-cap.js: add the stale core-lock drift guard — fail the build with
  an actionable message when the mirrored core's dependencies diverge from the
  frozen "core" entry in src/package-lock.json (the biggest latent break: it
  would otherwise surface only as an out-of-sync `npm ci` downstream). Also
  guard the pre-merge lockfile JSON.parse for symmetry with the later block.
  New guardrail test covers the drift case; the base fixture now carries the
  core's declared deps like the real lock.
- ESLint flat config + `npm run lint` + CI gate over the build scripts, the
  builder tests and the CAP app source (src/srv, src/test).
- dependabot: watch the npm ecosystem in /src (the app lock was untended).
- server.js: document the auth boundary — data endpoints (POST roundtrip +
  OData) are @requires-protected; the GET/HEAD routes serve only the static
  shell + CSRF ack and are intentionally public.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018FTxX214GdPJZXvz88Mbq8
@oblomov-dev
oblomov-dev merged commit a3c5ef4 into main Jul 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants