-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Do not rely on the X-<protocol>-User HTTP header to detect a protocol #16015
Do not rely on the X-<protocol>-User HTTP header to detect a protocol #16015
Conversation
In which cases is that header not provided? |
if (headerNames.contains("X-" + alternateHeaderName.get() + "-User")) { | ||
if (headerNames.contains("X-Trino-User")) { | ||
String headerPrefix = "x-" + alternateHeaderName.get().toLowerCase(ENGLISH); | ||
if (headerNames.stream() |
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.
Nit: these would look better without wrapping
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.
You mean something like:
if (headerNames.stream().anyMatch(header -> header.toLowerCase(ENGLISH).startsWith(headerPrefix))) {
if (headerNames.stream().anyMatch(header -> header.toLowerCase(ENGLISH).startsWith("x-trino-"))) {
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.
Yep, exactly
Now that we do user mapping for authentication, it's legitimate for a client not to send the user header, and apparently some clients do not always send it. |
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
Can you clarify what the next here should be @electrum ? |
Description
Change the logic to detect a non-Trino protocol to stop relying on the X--User HTTP header.
Additional context and related issues
Trino detects alternative protocols (e.g. Presto) by looking whether the X--User HTTP header exists. In some cases however no such header is provided. So change the logic to avoid relying on that particular HTTP header and instead look for any X--* HTTP header.
Release notes
(X) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: