Reconcile: your admin wins, keeping main's non-admin work

You built a self-service catalogue admin on feature/admin-and-ui-wins while I built a
competing one that had already merged and deployed. Both forked from c8cc8fe. Per your
call, your implementation is the one that stays.

Kept from main (files your branch didn't touch, so no conflict):
- the CI test gate (tests now run and block the image)
- motion 12.42.2
- the platform contract test

Took from your branch:
- split AdminProductController / AdminCategoryController + ProductPhotoService (server-side
  webp via cwebp)
- a real category table (Category, V3__categories.sql) behind the product filters
- pages/Admin.tsx, with server-side /admin protection that redirects a browser to Authentik
  and returns it to /admin afterward — cleaner than my client-side gate, and it avoids the
  post-login-to-home issue my version had

Deleted my competing admin (AdminController, MeController, pages/admin/*, auth.tsx, and my
admin tests).

Grafted onto your gallery: swipe + arrow keys, which the deployed version had and yours
didn't. Added an AdminSecurityTest for your endpoints (admin closed, shop public, contact
CSRF) — the admin was otherwise untested, and CI now gates on tests.

Verified against a running container: /admin redirects a browser to Authentik (a bare 401
only for */* fetches, which is correct). 25 tests green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XXKjx7FNyRVAjU8dgB5KhN
This commit is contained in:
2026-07-23 13:10:46 -05:00
co-authored by Claude Opus 4.8
parent 021dd0db8d
commit 651ff1e30c
26 changed files with 1790 additions and 1037 deletions
+29 -15
View File
@@ -36,30 +36,44 @@ platform:
data:
auditing:
enabled: true
security:
# Public site: only the admin API needs a login. An allowlist of public paths would mean
# enumerating every static directory, and anything missed 401s — which is exactly how the
# confessions site broke its own cover images. mode=OIDC comes from the deploy env so tests
# stay on NONE.
authenticated-paths:
- /api/admin/**
storage:
endpoint: ${S3_ENDPOINT:https://s3.thebennett.net}
access-key: ${S3_ACCESS_KEY:}
secret-key: ${S3_SECRET_KEY:}
path-style-access: true
contact:
to: ${CONTACT_TO:}
from: ${CONTACT_FROM:}
hub-url: ${CONTACT_HUB_URL:}
vine:
security:
# Unset means the platform's permit-all chain, which is what a brochure site wants and what the
# web contract expects (an unknown /api path must 404, not 401). Set SECURITY_MODE=OIDC in the
# deployment to turn on Authentik login — that, and only that, brings the admin endpoints into
# existence. Leaving it unset in dev keeps `mvn spring-boot:run` working with no identity provider.
mode: ${SECURITY_MODE:NONE}
permit-paths:
- /api/products
- /api/categories
- /api/contact
- /actuator/health/**
authenticated-paths:
- /api/admin/**
# The admin screen itself, not just its API. The platform sends /api/** a bare 401 (right for
# fetch) but bounces everything else to Authentik, so protecting the page means a browser that
# opens /admin lands on the login form and comes back signed in — rather than loading an editor
# whose every request immediately fails. It also keeps the page out of strangers' hands entirely.
- /admin/**
storage:
bucket: ${VINE_BUCKET:itsthevine}
# Only consulted when someone uploads a photo, i.e. only in a deployment that also set OIDC above.
# Blank endpoint leaves the storage auto-config switched off, so tests and local runs boot without
# MinIO credentials.
endpoint: ${STORAGE_ENDPOINT:}
access-key: ${STORAGE_ACCESS_KEY:}
secret-key: ${STORAGE_SECRET_KEY:}
# Absolute URLs for og:url. Only matters to link-preview scrapers, which need a full URL.
site:
base-url: ${SITE_BASE_URL:https://itsthevine.com}
assets:
# Where uploaded photos land. The key stored on a product is bucket-relative and excludes the
# prefix, because ProductCatalog re-adds `/images/` when it builds the public URL.
bucket: ${STORAGE_BUCKET:itsthevine}
key-prefix: images/
management:
endpoints:
@@ -0,0 +1,26 @@
-- The filter buttons were a hard-coded List.of(...) in ProductCatalog. That meant adding a category
-- was a deploy, and anything an editor invented appeared last, alphabetically, with no way to move
-- it. This makes the order data so the admin screens can arrange it.
--
-- product.category deliberately stays a varchar holding the name rather than becoming a foreign key:
-- every existing row, query and derived repository method keeps working untouched, and six rows of
-- reference data don't warrant rewriting the catalogue's shape. Renaming a category updates the
-- products alongside it, in one transaction.
create table category (
id bigserial primary key,
name varchar(60) not null unique,
position integer not null,
created_at timestamptz not null,
updated_at timestamptz
);
-- Seeded in the order the page has always shown them, so the site looks identical the moment this
-- lands. Categories found on products but missing here still appear on the filter (appended
-- alphabetically) rather than silently vanishing.
insert into category (name, position, created_at) values
('Cookies', 1, now()),
('Cakes', 2, now()),
('Rolls', 3, now()),
('Pie', 4, now()),
('Brownies', 5, now()),
('Pastries', 6, now());