From 26509394e0a6698ac6c28c2ca7cc3b0b952f2e71 Mon Sep 17 00:00:00 2001 From: Connor Snitker Date: Mon, 21 Sep 2026 10:43:06 -0500 Subject: [PATCH 1/4] fix(docs): make Swagger work on the deployed service origin Signed-off-by: Connor Snitker --- internal/adapter/docsui/openapi/ra.yaml | 40 ++----------------------- internal/adapter/docsui/openapi/tl.yaml | 4 +-- spec/api-spec-tl-v2.yaml | 4 +-- spec/api-spec-v2.yaml | 40 ++----------------------- 4 files changed, 8 insertions(+), 80 deletions(-) diff --git a/internal/adapter/docsui/openapi/ra.yaml b/internal/adapter/docsui/openapi/ra.yaml index 5f0784b..38d35c7 100644 --- a/internal/adapter/docsui/openapi/ra.yaml +++ b/internal/adapter/docsui/openapi/ra.yaml @@ -43,12 +43,8 @@ info: url: https://www.apache.org/licenses/LICENSE-2.0.html servers: - - url: http://localhost:18080/v2 - description: Local dev — quickstart ra-local.yaml - - url: https://api.ans.example.org/v2 - description: Main ANS API server (v2) - - url: https://test.ans.example.org/v2 - description: Test server (v2) + - url: /v2 + description: This Registration Authority (current service origin) tags: - name: Management @@ -2811,38 +2807,6 @@ components: - title - status - Problem: - type: object - description: | - RFC 7807 Problem Details — the actual error shape every RA failure - path emits, served as `application/problem+json`. Clients read - `code` for programmatic handling and `detail` for the - human-readable explanation. - - (The legacy `ErrorResponse` schema below is retained only for the - pre-existing routes still declared against it; new routes point - here. Migrating the remaining declarations is tracked separately.) - properties: - type: - type: string - description: URI reference identifying the problem type. - title: - type: string - description: Short, human-readable summary of the problem type. - status: - type: integer - description: HTTP status code. - detail: - type: string - description: Human-readable explanation specific to this occurrence. - code: - type: string - description: Stable, machine-readable error code for programmatic handling. - required: - - title - - status - - code - ErrorResponse: type: object properties: diff --git a/internal/adapter/docsui/openapi/tl.yaml b/internal/adapter/docsui/openapi/tl.yaml index d4ffa5b..e736a37 100644 --- a/internal/adapter/docsui/openapi/tl.yaml +++ b/internal/adapter/docsui/openapi/tl.yaml @@ -30,8 +30,8 @@ info: expose single-record lookup). servers: - - url: http://localhost:18081 - description: local dev (quickstart) + - url: / + description: This Transparency Log (current service origin) # ──────────────────────────────────────────────────────────────── # Tags group routes in generated docs by audience. diff --git a/spec/api-spec-tl-v2.yaml b/spec/api-spec-tl-v2.yaml index d4ffa5b..e736a37 100644 --- a/spec/api-spec-tl-v2.yaml +++ b/spec/api-spec-tl-v2.yaml @@ -30,8 +30,8 @@ info: expose single-record lookup). servers: - - url: http://localhost:18081 - description: local dev (quickstart) + - url: / + description: This Transparency Log (current service origin) # ──────────────────────────────────────────────────────────────── # Tags group routes in generated docs by audience. diff --git a/spec/api-spec-v2.yaml b/spec/api-spec-v2.yaml index 5f0784b..38d35c7 100644 --- a/spec/api-spec-v2.yaml +++ b/spec/api-spec-v2.yaml @@ -43,12 +43,8 @@ info: url: https://www.apache.org/licenses/LICENSE-2.0.html servers: - - url: http://localhost:18080/v2 - description: Local dev — quickstart ra-local.yaml - - url: https://api.ans.example.org/v2 - description: Main ANS API server (v2) - - url: https://test.ans.example.org/v2 - description: Test server (v2) + - url: /v2 + description: This Registration Authority (current service origin) tags: - name: Management @@ -2811,38 +2807,6 @@ components: - title - status - Problem: - type: object - description: | - RFC 7807 Problem Details — the actual error shape every RA failure - path emits, served as `application/problem+json`. Clients read - `code` for programmatic handling and `detail` for the - human-readable explanation. - - (The legacy `ErrorResponse` schema below is retained only for the - pre-existing routes still declared against it; new routes point - here. Migrating the remaining declarations is tracked separately.) - properties: - type: - type: string - description: URI reference identifying the problem type. - title: - type: string - description: Short, human-readable summary of the problem type. - status: - type: integer - description: HTTP status code. - detail: - type: string - description: Human-readable explanation specific to this occurrence. - code: - type: string - description: Stable, machine-readable error code for programmatic handling. - required: - - title - - status - - code - ErrorResponse: type: object properties: From 7ac5b523733e85a8122ce455bc2396ec2984ac11 Mon Sep 17 00:00:00 2001 From: Connor Snitker Date: Mon, 21 Sep 2026 16:12:35 -0500 Subject: [PATCH 2/4] fix(docs): use service origin for agent event feed Signed-off-by: Connor Snitker --- internal/adapter/docsui/openapi/ra.yaml | 6 ++---- spec/api-spec-v2.yaml | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/internal/adapter/docsui/openapi/ra.yaml b/internal/adapter/docsui/openapi/ra.yaml index 38d35c7..e4f1739 100644 --- a/internal/adapter/docsui/openapi/ra.yaml +++ b/internal/adapter/docsui/openapi/ra.yaml @@ -92,10 +92,8 @@ paths: # ────────────────────────────────────────────────────────────────── /v1/agents/events: servers: - - url: http://localhost:18080 - description: Local dev — quickstart ra-local.yaml (feed is not under /v2) - - url: https://api.ans.example.org - description: Main ANS API server + - url: / + description: This Registration Authority (current service origin) get: tags: - Events diff --git a/spec/api-spec-v2.yaml b/spec/api-spec-v2.yaml index 38d35c7..e4f1739 100644 --- a/spec/api-spec-v2.yaml +++ b/spec/api-spec-v2.yaml @@ -92,10 +92,8 @@ paths: # ────────────────────────────────────────────────────────────────── /v1/agents/events: servers: - - url: http://localhost:18080 - description: Local dev — quickstart ra-local.yaml (feed is not under /v2) - - url: https://api.ans.example.org - description: Main ANS API server + - url: / + description: This Registration Authority (current service origin) get: tags: - Events From cecdc6dc3f7bb6225ff2abeab3498a39c7a54a3d Mon Sep 17 00:00:00 2001 From: Connor Snitker Date: Fri, 2 Oct 2026 13:13:08 -0500 Subject: [PATCH 3/4] fix(docs): pin Swagger assets with subresource integrity Signed-off-by: Connor Snitker --- internal/adapter/docsui/docsui.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/internal/adapter/docsui/docsui.go b/internal/adapter/docsui/docsui.go index f2be6fd..fcf5d95 100644 --- a/internal/adapter/docsui/docsui.go +++ b/internal/adapter/docsui/docsui.go @@ -96,9 +96,9 @@ func Mount(r chi.Router, spec Spec) { // by itself — we pass it only the OpenAPI URL and a few cosmetic // options. dom_id anchors the app into the page body. func renderSwaggerUI(title string) string { - // Pin the Swagger UI version so upstream changes can't break - // local dev overnight. 5.17.x is the current LTS-ish series - // at the time of writing and works against OpenAPI 3.0 specs. + // Pin the package version and asset integrity together. The SRI hashes + // below are SHA-384 over files from the integrity-verified npm package. + // Browsers must reject modified CDN assets before they can read API tokens. const swaggerVersion = "5.17.14" // Escape the title in case it ever grows HTML-sensitive chars // — today it's plain ASCII but defense-in-depth costs nothing. @@ -109,7 +109,8 @@ func renderSwaggerUI(title string) string { %s + href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@%s/swagger-ui.css" + integrity="sha384-wxLW6kwyHktdDGr6Pv1zgm/VGJh99lfUbzSn6HNHBENZlCN7W602k9VkGdxuFvPn" crossorigin="anonymous">