Skip to content

Exempt /api/openapi.json and /torznab/api from auth middleware#6

Merged
JeremiahM37 merged 1 commit into
mainfrom
fix/openapi-and-torznab-public
May 14, 2026
Merged

Exempt /api/openapi.json and /torznab/api from auth middleware#6
JeremiahM37 merged 1 commit into
mainfrom
fix/openapi-and-torznab-public

Conversation

@JeremiahM37
Copy link
Copy Markdown
Owner

Summary

Two related auth-middleware fixes for endpoints that do their own auth internally:

  1. /api/openapi.json — public API spec for AI/tooling discovery (same precedent as /metrics and /health).
  2. /torznab/api and /api alias — the Torznab handler does its own apikey check against TORZNAB_API_KEY. Without exempting these paths, the gamarr auth middleware rejected Prowlarr requests with 401 (Prowlarr sends ?apikey=<torznab-key>, not the gamarr API_KEY) before they ever reached the Torznab handler.

Why this wasn't caught at v1.2.0

The LXC 104 isolated test deployment used no AUTH_USERNAME / API_KEY, so gamarr was in "anonymous admin" mode and the middleware passed everything through. The Torznab feature works fine there but breaks the moment a user configures authentication.

Test plan

  • New TestIsExempt with 23 path assertions (positive + negative + suffix-attack guards).
  • go test -race -count=1 ./... clean.
  • gofmt, vet, staticcheck clean.

Backwards compatibility

Strictly additive (paths added to the exempt list, none removed). The Torznab handler's own apikey check is unchanged and still gates access when TORZNAB_API_KEY is set.

Two related bypasses for path-handler-own-auth endpoints:

* /api/openapi.json — public API spec for AI/tooling discovery (same
  precedent as /metrics and /health, both already exempt).

* /torznab/api and /api alias — the Torznab handler does its own
  apikey check against TORZNAB_API_KEY. Without exempting these
  paths, the gamarr auth middleware rejected Prowlarr requests with
  401 (Prowlarr sends ?apikey=<torznab-key>, not the gamarr API_KEY)
  before they ever reached the Torznab handler. The /api alias is
  mounted on the exact path /api only, so this does NOT match
  /api/search, /api/library, etc.

The Torznab exemption was missed in the original v1.2.0 work because
the LXC 104 isolated test deployment used no AUTH_USERNAME / API_KEY,
so gamarr was in 'anonymous admin' mode and the middleware passed
everything through. The bug manifests only when the user configures
authentication.

New TestIsExempt locks in 23 positive + negative path assertions,
including suffix-attack guards.
@JeremiahM37 JeremiahM37 merged commit 8084136 into main May 14, 2026
4 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.

1 participant