Skip to content
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

Merged
merged 6 commits into from
Mar 7, 2022

Conversation

vitorenesduarte
Copy link
Contributor

@vitorenesduarte vitorenesduarte commented Mar 4, 2022

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.
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 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.
@vitorenesduarte vitorenesduarte self-assigned this Mar 4, 2022
@github-actions github-actions bot requested review from hatched and rosstimothy March 4, 2022 11:20
@github-actions github-actions bot added the tctl tctl - Teleport admin tool label Mar 4, 2022
@@ -107,14 +107,24 @@ func TestAuthSignKubeconfig(t *testing.T) {
wantError string
}{
{
desc: "--proxy specified",
desc: "--proxy specified with URL scheme",
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @knisbet. Added another test in a000f44.

Comment on lines 745 to 748
if u.Scheme == "" {
u.Scheme = "https"
}
a.proxyAddr = u.String()
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@vitorenesduarte vitorenesduarte merged commit f314e59 into master Mar 7, 2022
@vitorenesduarte vitorenesduarte deleted the vitor/default-scheme-proxy-flag branch March 7, 2022 10:04
vitorenesduarte pushed a commit that referenced this pull request Mar 7, 2022
…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.
vitorenesduarte pushed a commit that referenced this pull request Mar 7, 2022
…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.
vitorenesduarte pushed a commit that referenced this pull request Mar 8, 2022
…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.
vitorenesduarte pushed a commit that referenced this pull request Mar 8, 2022
…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.
@russjones russjones added the cloud Cloud label Mar 18, 2022
@webvictim webvictim mentioned this pull request Apr 19, 2022
@webvictim webvictim mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloud Cloud tctl tctl - Teleport admin tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants