-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable custom response headers for server #13045
Conversation
The server.customResponseHeaders configuration allows users to configure custom headers to send on all responses to the client from anywhere in the Kibana server. This can be useful for setting headers like x-frame-options when you don't want people embedding even Kibana dashboards in an iframe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor things, but LGTM. Should probably mention #8519 in the description.
src/server/http/index.js
Outdated
response.output.headers['kbn-version'] = kbnServer.version; | ||
response.output.headers = { | ||
...response.output.headers, | ||
...customResponseHeaders, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this branch the kbn-name
and kbn-version
headers overwrite the same keys in customResponseHeaders
, but in the branch below the opposite is true.
Perhaps you could merge customResponseHeaders
with kbn-name
and kbn-version
outside of this condition, then apply the update as necessary within the branches of the condition?
src/server/config/schema.js
Outdated
@@ -53,6 +53,7 @@ export default () => Joi.object({ | |||
autoListen: Joi.boolean().default(true), | |||
defaultRoute: Joi.string().default('/app/kibana').regex(/^\//, `start with a slash`), | |||
basePath: Joi.string().default('').allow('').regex(/(^$|^\/.*[^\/]$)/, `start with a slash, don't end with one`), | |||
customResponseHeaders: Joi.object().default({}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like omitting .keys()
here allows the object to have any keys, but I think it would be nice to have an explicit .unknown(true)
to be extra clear about that intention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand what any of that means :-/
@spalger I updated it based on your feedback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Configurable custom response headers for server The server.customResponseHeaders configuration allows users to configure custom headers to send on all responses to the client from anywhere in the Kibana server. This can be useful for setting headers like x-frame-options when you don't want people embedding even Kibana dashboards in an iframe. * Consistent header overriding and explicit unknown
5.x/5.6 cba3e93 |
* Configurable custom response headers for server The server.customResponseHeaders configuration allows users to configure custom headers to send on all responses to the client from anywhere in the Kibana server. This can be useful for setting headers like x-frame-options when you don't want people embedding even Kibana dashboards in an iframe. * Consistent header overriding and explicit unknown Conflicts: docs/setup/settings.asciidoc (cherry picked from commit cba3e93)
The server.customResponseHeaders configuration allows users to configure
custom headers to send on all responses to the client from anywhere in
the Kibana server.
This can be useful for setting headers like x-frame-options when you
don't want people embedding even Kibana dashboards in an iframe.
Apologies for the whitespace changes in the doc. The .asciidoc files do
not force removal of spaces at the end of lines, so someone committed
a bunch of erroneous spaces before and my edit removed them. I
recommend reviewing with ?w=1 in the github url.
In kibana.yml:
In terminal:
For #8519, though it doesn't close it necessarily.