-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add X-Elastic-Product header on all http responses #73434
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
Conversation
Pinging @elastic/es-core-features (Team:Core/Features) |
@@ -57,6 +57,8 @@ | |||
|
|||
private static final Logger logger = LogManager.getLogger(RestController.class); | |||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestController.class); | |||
private static final String ELASTIC_PRODUCT_HTTP_HEADER = "X-Elastic-Product"; |
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.
Should this be lowercase here? I noticed that many of the HTTP Headers we operate with are not consistently cased.
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.
According to the HTTP spec, header names are case-insensitive. We use lowercase for x-elastic-product-origin
but it shouldn't* matter.
*
famous last words
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 pending green CI. One non-blocking comment below for you to consider or decline as you prefer.
@@ -57,6 +57,8 @@ | |||
|
|||
private static final Logger logger = LogManager.getLogger(RestController.class); | |||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestController.class); | |||
private static final String ELASTIC_PRODUCT_HTTP_HEADER = "X-Elastic-Product"; |
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.
According to the HTTP spec, header names are case-insensitive. We use lowercase for x-elastic-product-origin
but it shouldn't* matter.
*
famous last words
@@ -142,6 +143,9 @@ public MethodHandlers next() { | |||
assertEquals("true", threadContext.getHeader("header.1")); | |||
assertEquals("true", threadContext.getHeader("header.2")); | |||
assertNull(threadContext.getHeader("header.3")); | |||
List<String> expectedProductResponseHeader = new ArrayList<>(); | |||
expectedProductResponseHeader.add("Elasticsearch"); | |||
assertEquals(expectedProductResponseHeader, threadContext.getResponseHeaders().getOrDefault("X-Elastic-Product", null)); |
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.
Maybe make the ELASTIC_PRODUCT_HTTP_HEADER
variable package private so it can be referenced here instead of the string literal?
Failing test was because security expects only 3 headers to be output when a request is not authenticated: |
@elasticmachine update branch |
@elasticmachine update branch |
@jbaiera this should be backported to |
@swallez thanks for the reminder, backport is in flight |
Follow-up to elastic#73434 Ensures that High Level Rest Client is running against a verified Elasticsearch. When the first request is send on HLRC, a request to the info endpoint is made first to verify the product identification and version.
Follow-up to #73434 Ensures that High Level Rest Client is running against a verified Elasticsearch. When the first request is send on HLRC, a request to the info endpoint is made first to verify the product identification and version.
Follow-up to #73434 Ensures that High Level Rest Client is running against a verified Elasticsearch. When the first request is send on HLRC, a request to the info endpoint is made first to verify the product identification and version.
This PR adds a header to all Elasticsearch responses that confirms the type of service operating on the other end of the connection. This will aid in validating client-server connections to ensure protocol compatibility between requestors and the server.
The header returns from all requests (except unauthenticated ones) and its format is as follows:
resolves #73424
edit: Updated the default casing of the header, updated that it is not returned on unauthenticated requests.