Skip to content
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

Merged
merged 2 commits into from
Jul 21, 2017

Conversation

epixa
Copy link
Contributor

@epixa epixa commented Jul 21, 2017

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:

server.customResponseHeaders: { "X-Frame-Options": "DENY" }

In terminal:

$ curl -I localhost:5601
HTTP/1.1 200 OK
kbn-name: kibana
kbn-version: 6.0.0-beta1
x-frame-options: DENY
vary: origin
cache-control: no-cache
Date: Fri, 21 Jul 2017 20:30:48 GMT
Connection: keep-alive

For #8519, though it doesn't close it necessarily.

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.
Copy link
Contributor

@spalger spalger left a 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.

response.output.headers['kbn-version'] = kbnServer.version;
response.output.headers = {
...response.output.headers,
...customResponseHeaders,
Copy link
Contributor

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?

@@ -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({}),
Copy link
Contributor

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.

Copy link
Contributor Author

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 :-/

@epixa
Copy link
Contributor Author

epixa commented Jul 21, 2017

@spalger I updated it based on your feedback

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@epixa epixa merged commit 7a918f1 into elastic:master Jul 21, 2017
@epixa epixa deleted the customresponseheaders branch July 21, 2017 22:35
epixa added a commit that referenced this pull request Jul 21, 2017
* 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
@epixa
Copy link
Contributor Author

epixa commented Jul 21, 2017

5.x/5.6 cba3e93

JanZerebecki pushed a commit to JanZerebecki/kibana that referenced this pull request Jun 9, 2021
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants