-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Check for port before setting Origin header for watch requests. #1669
Conversation
When the Kubernetes URL used doesn't specify a port (e.g., https://example.com/api/v1/...), the origin header for watch requests ends up with a port of -1 (e.g. https://example.com:-1). This happens because calling `getPort()` on a java.net.URL object that does not have a port explicitly specified will always return -1. The return value was always just inserted into the origin header. Now, we check for this and only append a port to the origin header if `getPort()` returns something other than -1. We make this change in both the WatchConnectionManager and WatchHTTPManager classes.
Can one of the admins verify this patch? |
Ok to test |
ok to test |
Do we need an origin header at all? That’s really just useful for protecting browsers from cross site scripting. Could we simply drop the header all together? |
@kjcjohnson: Could you please test your patch without header? If it's not breaking anything then let's drop it. |
It looks like dropping the origin header won't work. I took some Wireshark captures of the packets, and they're identical other than the Origin header, but only the request with the header succeeds: Without Origin header:
With Origin header:
|
Co-Authored-By: George Gastaldi <gegastaldi@gmail.com>
[merge] |
Pull request is not mergeable. |
To get the fix in fabric8io/kubernetes-client#1669 Origin header is set with port -1 when no port is present in the Kubernetes API url
To get the fix in fabric8io/kubernetes-client#1669 Origin header is set with port -1 when no port is present in the Kubernetes API url Causing an error on exec ``` java.net.ProtocolException: Expected HTTP 101 response but was '403 Forbidden' ```
Update plugins to pickup fix for origin headers found here fabric8io/kubernetes-client#1669
Update plugins to pickup fix for origin headers found here fabric8io/kubernetes-client#1669
Update plugins to pickup fix for origin headers found here fabric8io/kubernetes-client#1669
When the Kubernetes URL used doesn't specify a port
(e.g., https://example.com/api/v1/...), the origin header for
watch requests ends up with a port of -1 (e.g., https://example.com:-1).
This happens because calling
getPort()
on a java.net.URL object thatdoes not have a port explicitly specified will always return -1. The
return value was always just inserted into the origin header.
Now, we check for this and only append a port to the origin header if
getPort()
returns something other than -1. We make this change in boththe WatchConnectionManager and WatchHTTPManager classes.
I wasn't able to come up with a way to make a test for this, because the
mock Kubernetes server doesn't support specifying the port, and especially not
the defaults of 80/443.
Fixes #1667