Skip to content

KAFKA-21113: Apply response.http.headers.config to the Connect admin listener - #23494

Open
ashwinpankaj wants to merge 2 commits into
apache:trunkfrom
ashwinpankaj:connect-admin-listener-security-fixes
Open

ashwinpankaj wants to merge 2 commits into
apache:trunkfrom
ashwinpankaj:connect-admin-listener-security-fixes

Conversation

@ashwinpankaj

Copy link
Copy Markdown
Contributor

Fixes KAFKA-21113: RestServer.initializeResources() builds a separate ServletContextHandler adminContext whenever admin.listeners is configured to a distinct value, but configureHttpResponseHeaderFilter was only ever called on the regular context. response.http.headers.config is commonly used for security-hardening headers (the existing test suite itself uses X-XSS-Protection, Cache-Control, and references X-Frame-Options), so these were silently missing from all admin endpoint responses whenever a distinct admin listener was configured.

This is the same "regular-only, admin left out" bug shape already fixed for REST extension registration in #23150. Fix: call configureHttpResponseHeaderFilter(adminContext, headerConfig) too, guarded on adminContext != null, mirroring the guard already used elsewhere in the same method (adminContext.start(), extension registration). Added testCustomizedHttpResponseHeadersAppliedToAdminContext asserting the configured headers appear on server.adminUrl() responses.

Also includes a small, related test fix raised in review on #23150: this comment pointed out that testRestExtensionsWithoutAdminListener only checked /connectors via advertisedUrl(), not /admin/loggers, even though in the no-separate-admin-listener case admin resources fall back to sharing the regular ResourceConfig and should be reachable the same way. Bundling it here since it's the same file and the same reviewer thread.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

…listener case

Addresses a review comment on apache#23150 (the REST-extension-registration
refactor): when admin.listeners is unset, admin resources fall back
to sharing the regular ResourceConfig, so /admin/loggers should be
reachable via advertisedUrl() with REST extension filters applied,
same as any other resource on that listener. testRestExtensionsWithoutAdminListener
only checked /connectors; add the equivalent assertion for /admin/loggers.
RestServer.initializeResources() only ever called
configureHttpResponseHeaderFilter on the regular ServletContextHandler,
never on the admin one. Same bug shape as the REST-extension-registration
fix in the previous commit and apache#23150: when admin.listeners points at a
distinct listener, response.http.headers.config -- commonly used for
security headers like X-XSS-Protection, X-Frame-Options, Cache-Control --
was silently missing on all admin responses.

Guard on adminContext != null, mirroring the existing pattern already
used elsewhere in this method for admin resources/extensions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connect small Small PRs triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant