-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Issue #7250 - Update HostHeaderCustomizer for empty Host + no authority #7251
Conversation
Signed-off-by: Joakim Erdfelt <[email protected]>
There is an argument that we should not be setting or caring about the authority. If we get a request like ...
That is a request without a declared authority, as specified by https://datatracker.ietf.org/doc/html/rfc7230#section-5.4 For example If we reach a webapp in the above request that does Question still remaining, do we force the |
…eaderCustomizer Signed-off-by: Joakim Erdfelt <[email protected]>
Needs more tests for bad Example:
Should these be fixed by We'll also need a new module for this new customizer. |
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
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'd really REALLY prefer not to make any changes to HttpURI
.
Instead focus on making a really good RejectInvalidAuthorityCustomizer
that will solve the main concern of this PR.
Then by all means tweak the other Customizers to make them do a better job in the edge cases, but they don't need to be perfect if we have a good RIAC
// Host must start with alpha-numeric. | ||
int c = host.codePointAt(0); | ||
if (!Character.isLetterOrDigit(c)) | ||
return false; |
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.
What about IPv6, which can start with '['
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.
handled in different path, and in uncommited code i mentioned.
@Override | ||
public void customize(Connector connector, HttpConfiguration channelConfig, Request request) | ||
{ | ||
if (!isValidAuthority(request.getHttpURI())) |
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.
Is this correct? Don't we just care that there is an Authority in eitehr the URI or Host header (and if both then they match)?
Or has this been handled for us already and any Host header already copied over to the URI authority?
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.
Handled differently now, in HostPort
.
String hostHeaderValue = request.getHeader("Host"); | ||
|
||
// No Host Header | ||
if (request.getHttpVersion().getVersion() != HttpVersion.HTTP_1_1.getVersion() && |
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.
This can cause NPE, isn't it? request.getHttpVersion() can return 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.
The request shouldn't reach this customizer then, as I would expect the request to fail well before the customizers have been called.
This PR will be split into separate PRs. |
This PR has now been broken down into ... |
Signed-off-by: Joakim Erdfelt [email protected]