Date: 2026-08-22
Accepted
Every existing /api/v1/... endpoint is authenticated by SessionFilter/Auth against a session cookie (islandr_session) — designed for one specific client (the Vue SPA) that can complete an interactive login. That's the right model for the UI, but it has no path for a script, CI pipeline, or monitoring scraper (e.g. a Prometheus server, Issue #71) that needs to call Islandr without a browser session.
There's a second, independent problem beyond auth: the internal /api/v1 resources are shaped for whatever the SPA currently needs and are free to change as the SPA evolves (a field renamed, a response reshaped, an endpoint split) — that's normal, healthy internal API evolution. An external consumer (a Terraform provider, a shell script in someone's CI, a homegrown dashboard) needs the opposite guarantee: a contract that doesn't shift under them just because the admin console's UI changed. Bolting Bearer-token auth onto the existing internal resources would accidentally promise that stability without ever deciding to.
A separate, versioned external API facade under /api/external/v1/..., authenticated by API keys (Authorization: Bearer islandr_<random>) instead of session cookies — parallel to, not layered onto, the internal SPA-facing API.
ApiKeyAuthFilter simply stops accepting it. Mirrors how Session revocation already works.PeerExternalResource, UserExternalResource, etc. under /api/external/v1/ are new, deliberately narrow JAX-RS resource classes. They call into the same underlying services the internal resources already use (PeerService, UserService, ...) — no duplicated business logic — but they own their own request/response DTOs and their own URL shape, so the internal API can keep evolving for the SPA without silently breaking an external integration, and the external surface can stay small (only what's actually meant to be automated) rather than accidentally exposing every internal implementation detail.
docs/api/openapi.yml describes the external facade only (never the internal SPA API) and is maintained by hand — or by an offline tool a maintainer runs locally and commits the output of — but never by a runtime annotation-processing extension bundled into the shipped application. Concretely: no quarkus-smallrye-openapi (or equivalent) dependency in build.gradle.kts.
Reasoning: a Prometheus-style /metrics endpoint or a CI script consulting the spec never needs Islandr itself to generate that spec at request time — the spec is a documentation/client-generation artifact consumed by humans and tools (e.g. openapi-generator) outside the running instance, not something the running instance must produce for anyone who asks. Pulling in a runtime OpenAPI extension purely to render a document nobody queries at runtime would add build-time annotation processing and binary size to every native-image build, for every user, to serve a use case (spec authoring) that happens at development time for one person (the maintainer). This is the same "hand-rolled over library, no dependency for something used rarely/offline" reasoning as the ACME client (ADR-0019) and DNS resolver (ADR-0023).
Deliberately starts small: read-mostly access to the resources #15 and #71 actually need (peers list/create, users list) rather than mirroring every internal resource on day one. Each additional facade resource is an incremental, reviewable addition to the same pattern — not a big-bang full-CRUD surface.
Implementation update (2026-08-23): sites (list), resources (list), and roles (list) added, read-only — the precondition ADR-0027 named for a useful MCP tool surface (an assistant can now see sites/resources/roles, though ACL grants themselves are still internal-only). Same pattern as peers/users: new narrow resource classes (SiteExternalResource, ResourceExternalResource, RoleExternalResource) delegating to the existing SiteService/ResourceService/RoleService, no duplicated logic.
Baseline: separate facade + API-key auth + hand-written OpenAPI (the decision). +1 better, 0 equal, −1 worse.
| Criterion (weight) | Separate facade, hand-written spec (baseline) | Bolt Bearer-auth onto internal /api/v1 |
Separate facade, runtime-generated OpenAPI (quarkus-smallrye-openapi) |
Separate facade, no formal spec (prose docs only) | OAuth2/JWT instead of static API keys |
|---|---|---|---|---|---|
| External contract stays stable across internal/SPA changes (5) | 0 | −1 | 0 | 0 | 0 |
| Native-image build size / build-time cost (4) | 0 | 0 | −1 | 0 | −1 |
| Spec stays accurate, not stale (3) | 0 | 0 | +1 | −1 | 0 |
| Implementation effort (2) | 0 | +1 | +1 | +1 | −1 |
| Fits self-hosted-script/CI use case without extra moving parts (3) | 0 | 0 | 0 | 0 | −1 |
| Weighted total | 0 | −5 | −1 | −3 | −9 |
Notes:
/api/v1 — least code, but every future SPA-driven reshape of an internal endpoint becomes a silent breaking change for anyone automating against it. The −5 is almost entirely that one criterion; this is the mistake this ADR exists to avoid.de.chriscohnen.islandr.apikey: ApiKey entity, ApiKeyService (generate/list/revoke), ApiKeyAuthFilter (parallel to SessionFilter, populates the same AuthContext shape so downstream code doesn't need to know which auth path fired), ApiKeyResource (admin-console CRUD, session-authenticated like every other admin page)./api/external/v1/... resource classes, additive to (never replacing) the internal /api/v1 ones.docs/api/openapi.yml becomes a maintained artifact — checked in, versioned, kept honest by (eventually) a contract test that validates real facade responses against it, not by a runtime generator. Implementation update (2026-08-23): the canonical file actually lives at src/main/resources/META-INF/resources/api/openapi.yml, served as a plain static file (the same mechanism that already serves index.html/CSS/JS — no runtime OpenAPI extension involved) at GET /api/openapi.yml, reachable without authentication and regardless of the externalApiEnabled toggle below (it's documentation, not a facade call). docs/api/openapi.yml is a symlink to that file, so there is still exactly one copy — avoiding the R-185 drift risk between "the docs copy" and "the served copy" by construction, not by discipline.Settings.externalApiEnabled (default true) lets an admin turn the whole facade off — every /api/external/v1/* route then 404s (not 401/403 — same "don't confirm this exists" posture ADR-0023's DNS resolver already applies) regardless of an otherwise-valid API key. Enforced by a single ExternalApiToggleFilter. This is explicit hardening on top of API-key auth, not a replacement for it — the facade was already access-controlled; this just lets an operator who never intends to use it remove the surface area entirely. Exposed in the Settings page, next to the other global feature toggles (gravatarEnabled, selfServicePeerCreation, ...). The DTO field is a nullable Boolean, not a primitive boolean — a lesson from a real bug this surfaced: several pre-existing tests reconstruct a full SettingsDto.UpdateRequest from a stale/partial object, and a primitive boolean silently defaults to false on any JSON body that omits the field, which would have quietly disabled the facade for the rest of a test JVM's run. null meaning "leave unchanged" (the same convention already used for wgMtu in this DTO) closes that hole structurally instead of relying on every caller remembering the new field.openapi.yml. Mitigation: keep the facade resource surface intentionally small (per-endpoint additions are reviewable) and treat "update the spec" as part of the same change, not a follow-up; a contract test against the spec is a natural next hardening step once the facade has more than a couple of endpoints./metrics exporter, the first concrete consumer of the API-key auth path