-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Default to https
scheme for --proxy
argument in tctl auth sign
#10844
Conversation
Fixes https://github.com/gravitational/cloud/issues/1358. Before this PR, if `--proxy` was set, it would be passed as it to the kubeconfig file. Due to this, if the `--proxy` URL did not have a scheme, it would default to `http, leading to the issue reported in https://github.com/gravitational/cloud/issues/1358. With this PR, we now try to parse the `--proxy` URL and set its scheme to `https` in case it's not set.
@@ -107,14 +107,24 @@ func TestAuthSignKubeconfig(t *testing.T) { | |||
wantError string | |||
}{ | |||
{ | |||
desc: "--proxy specified", | |||
desc: "--proxy specified with URL scheme", |
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: add tests as well for invalid cases. IE you get the expected error when using an invalid proxy address.
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.
tool/tctl/common/auth_command.go
Outdated
if u.Scheme == "" { | ||
u.Scheme = "https" | ||
} | ||
a.proxyAddr = u.String() |
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.
Probably minimal gain but you could avoid the call to u.String()
in the event the scheme is present. Since we are now parsing the user input should we also limit the provided scheme to only be https
or http
?
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.
Thanks for the review @rosstimothy. Tried to do this in 5bf4fdc.
…10844) Before this commit, if `--proxy` was set, it would be passed as it to the kubeconfig file. Due to this, if the `--proxy` URL did not have a scheme, it would default to `http`, leading to the issue reported in https://github.com/gravitational/cloud/issues/1358. With this commit, we now try to parse the `--proxy` URL and set its scheme to `https` in case it's not set. In case it's set, we only allow `--proxy` URLs with the `http` and `https` schemes.
…10844) Before this commit, if `--proxy` was set, it would be passed as it to the kubeconfig file. Due to this, if the `--proxy` URL did not have a scheme, it would default to `http`, leading to the issue reported in https://github.com/gravitational/cloud/issues/1358. With this commit, we now try to parse the `--proxy` URL and set its scheme to `https` in case it's not set. In case it's set, we only allow `--proxy` URLs with the `http` and `https` schemes.
…10844) (#10911) Before this commit, if `--proxy` was set, it would be passed as it to the kubeconfig file. Due to this, if the `--proxy` URL did not have a scheme, it would default to `http`, leading to the issue reported in https://github.com/gravitational/cloud/issues/1358. With this commit, we now try to parse the `--proxy` URL and set its scheme to `https` in case it's not set. In case it's set, we only allow `--proxy` URLs with the `http` and `https` schemes.
…10844) (#10910) Before this commit, if `--proxy` was set, it would be passed as it to the kubeconfig file. Due to this, if the `--proxy` URL did not have a scheme, it would default to `http`, leading to the issue reported in https://github.com/gravitational/cloud/issues/1358. With this commit, we now try to parse the `--proxy` URL and set its scheme to `https` in case it's not set. In case it's set, we only allow `--proxy` URLs with the `http` and `https` schemes.
Fixes https://github.com/gravitational/cloud/issues/1358.
Before this PR, if
--proxy
was set, it would be passed as it to the kubeconfig file. Due to this, if the--proxy
URL did not have a scheme, it would default tohttp
, leading to the issue reported in https://github.com/gravitational/cloud/issues/1358.With this PR, we now try to parse the
--proxy
URL and set its scheme tohttps
in case it's not set.In case it's set, we only allow
--proxy
URLs with thehttp
andhttps
schemes.