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

feat: Support Bearer token auth when get chart #8447

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lemonli
Copy link
Contributor

@lemonli lemonli commented Jul 14, 2020

Signed-off-by: lemonli liwenjun0323@gmail.com

What this PR does / why we need it:
PR for #8392
Special notes for your reviewer:

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@helm-bot helm-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 14, 2020
Copy link
Collaborator

@mattfarina mattfarina left a comment

Choose a reason for hiding this comment

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

Thanks for the PR linked to the issue. Helm follows SemVer so the function signature cannot change.

pkg/repo/chartrepo.go Outdated Show resolved Hide resolved
@lemonli
Copy link
Contributor Author

lemonli commented Jul 20, 2020

@mattfarina Would you please review again? Thanks.

}

// FindChartInAuthRepoURL finds chart in chart repository pointed by repoURL
// without adding repo to repositories, like FindChartInRepoURL,
// but it also receives credentials for the chart repository.
// Deprecated: this function is deprecated and will be removed in Helm 4, please use FindChartInRepoURLWithAuth instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

@mattfarina - do you think this is the best way to avoid modifying the public API? I'm not coming up with a good alternative given that this function takes other positional args such as "username" "password".

Should we take this moment to redesign the function to be more future proof? In the case there are more args? We can maybe use options to do things like FindChartInRepoURLWithAuth(WithCaFile(...), WithToken(...) ... instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jdolitsky I think this is a good way as you said.
@mattfarina I can update my commit if you agree with this.

@lemonli
Copy link
Contributor Author

lemonli commented Jul 28, 2020

@jdolitsky I have updated my commit, would you please review again? Thanks.

Copy link
Contributor

@jdolitsky jdolitsky left a comment

Choose a reason for hiding this comment

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

Sorry for delay. Looks pretty good! just one comment

Comment on lines 330 to 333
// Download and write the index file to a temporary location
buf := make([]byte, 20)
rand.Read(buf)
name := strings.ReplaceAll(base64.StdEncoding.EncodeToString(buf), "/", "-")
repoOpts := options{}
for _, opt := range opts {
opt(&repoOpts)
}

c := Entry{
URL: repoOpts.repoURL,
Username: repoOpts.username,
Password: repoOpts.password,
CertFile: repoOpts.certFile,
KeyFile: repoOpts.keyFile,
CAFile: repoOpts.caFile,
Name: name,
Token: repoOpts.token,
}
r, err := NewChartRepository(&c, getters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since most of this (besides relating to token) is reused from FindChartInAuthRepoURL, can we move it into a private helper function such as findChartInAuthRepoURL(token) so that the file has overall less lines of code?

Copy link
Contributor Author

@lemonli lemonli Sep 11, 2020

Choose a reason for hiding this comment

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

@jdolitsky I have updated my commit, would you please review again? Thanks.

@lemonli lemonli force-pushed the feat/chart-token branch 2 times, most recently from 9e3e0da to 8b76c12 Compare September 11, 2020 07:32
Copy link
Contributor

@jdolitsky jdolitsky left a comment

Choose a reason for hiding this comment

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

LGTM

@bacongobbler
Copy link
Member

needs a rebase before it can be merged.

@lemonli lemonli force-pushed the feat/chart-token branch 2 times, most recently from 9a7bd36 to 38320af Compare September 21, 2020 07:41
@lemonli
Copy link
Contributor Author

lemonli commented Sep 21, 2020

needs a rebase before it can be merged.

done

Copy link
Collaborator

@mattfarina mattfarina left a comment

Choose a reason for hiding this comment

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

I wanted to share the hold up I'm having with this PR.

Someone should not pass the bearer token in via the command because it will get caught up in the shell history. This is a security issue. Avoiding this with passwords is why Helm has the ability to read it from stdin.

There is also the case that the dearer token changes. Storing the bearer token so that it's used 6 months or a year from now doesn't seem like a good idea. It should expire. How does someone update that?

Does anyone have thoughts on these issues?

@marcosnils
Copy link

Someone should not pass the bearer token in via the command because it will get caught up in the shell history. This is a security issue. Avoiding this with passwords is why Helm has the ability to read it from stdin.

You can always set the token in an env var and pass it with --token $MYTOKEN. Mayabe eventually having a --token-stdin like docker login has could be a good idea, but I IMHO doesn't seem to be such a big of a concern that needs this PR to be held.

In addition to my previous comment, this also happens with username and password correct? Doesn't seem to be any difference there.

There is also the case that the dearer token changes. Storing the bearer token so that it's used 6 months or a year from now doesn't seem like a good idea. It should expire. How does someone update that?

Not sure I follow. Updating and rotating the token should be the user's concern? I guess the same happens with username/passowrd also right?

@mattfarina
Copy link
Collaborator

Someone should not pass the bearer token in via the command because it will get caught up in the shell history. This is a security issue. Avoiding this with passwords is why Helm has the ability to read it from stdin.

You can always set the token in an env var and pass it with --token $MYTOKEN. Mayabe eventually having a --token-stdin like docker login has could be a good idea, but I IMHO doesn't seem to be such a big of a concern that needs this PR to be held.

The Helm project is rounding out a second security review that included things like a threat analysis. The details will be released soon. These types of things were a topic of conversation in that process. This is the kind of security some ask of Helm.

When you specify a username and no password, Helm will prompt you enter it via stdin. This way it's not caught in the shell history.

The usage of stdin matters. For this example, I'll use CIrcleCI. CircleCI has something called secrets masking where the value of an environment variable is masked when used with print and echo. That means it won't, for example, be masked if you use it with the --password flag on the docker login command. CircleCI isn't the only CI system that does things like this.

A password could be inadvertently exposed through a CI system. This is something we want to take seriously on Helm.

In the name of security, we need a stdin based method to accept a token. That way you can do something like...

$ echo $TOKEN | helm repo add foo https://foo.example.com --token-stdin

This security issue is my primary hangup.

@marcosnils
Copy link

In the name of security, we need a stdin based method to accept a token. That way you can do something like...

I'm not going to go against something that improves the security of any project. If we can add this faeture also it'd be awesome. Not sure what's @lemonli's bandwidth to do it.

@hobbytp
Copy link

hobbytp commented Oct 15, 2020

Any update here? it is useful feature, can we separate the submit to more steps, first with --token $MYTOKEN, and 2nd step to add "--token-stdin"?

@josedev-union
Copy link

josedev-union commented Nov 11, 2020

I hope @jdolitsky or @lemonli can have a chance to make a workaround for --token-stdin soon.

@lemonli
Copy link
Contributor Author

lemonli commented Nov 12, 2020

Sorry for delay. I will update my commit to support --token-stdin soon.

@lemonli
Copy link
Contributor Author

lemonli commented Nov 25, 2020

Someone should not pass the bearer token in via the command because it will get caught up in the shell history. This is a security issue. Avoiding this with passwords is why Helm has the ability to read it from stdin.

You can always set the token in an env var and pass it with --token $MYTOKEN. Mayabe eventually having a --token-stdin like docker login has could be a good idea, but I IMHO doesn't seem to be such a big of a concern that needs this PR to be held.

The Helm project is rounding out a second security review that included things like a threat analysis. The details will be released soon. These types of things were a topic of conversation in that process. This is the kind of security some ask of Helm.

When you specify a username and no password, Helm will prompt you enter it via stdin. This way it's not caught in the shell history.

The usage of stdin matters. For this example, I'll use CIrcleCI. CircleCI has something called secrets masking where the value of an environment variable is masked when used with print and echo. That means it won't, for example, be masked if you use it with the --password flag on the docker login command. CircleCI isn't the only CI system that does things like this.

A password could be inadvertently exposed through a CI system. This is something we want to take seriously on Helm.

In the name of security, we need a stdin based method to accept a token. That way you can do something like...

$ echo $TOKEN | helm repo add foo https://foo.example.com --token-stdin

This security issue is my primary hangup.

@mattfarina I have updated my commit, looking forward to your reply.

@jrgwv
Copy link

jrgwv commented Dec 28, 2020

Hi folks, any update on when this might become available?

Signed-off-by: lemonli <liwenjun0323@gmail.com>
@ztbrown
Copy link

ztbrown commented Jan 27, 2021

Any update on this?

@cuttingedge1109
Copy link

cuttingedge1109 commented Jan 27, 2021

@lemonli seems need to rebase again before merge
3ad08f3 is conflicting

@ztbrown
Copy link

ztbrown commented Jan 27, 2021

@lemonli I have rebased your branch locally. Let me know if you'd like me to PR that to your repo.

@lemonli
Copy link
Contributor Author

lemonli commented Jan 28, 2021

@lemonli I have rebased your branch locally. Let me know if you'd like me to PR that to your repo.

Sure, thanks @ztbrown

@ztbrown
Copy link

ztbrown commented Jan 28, 2021

lemonli#1

@gimler
Copy link

gimler commented Mar 18, 2021

what is the state of this pr?

@almed4
Copy link

almed4 commented Jun 25, 2021

Can we get an update? Really looking forward to this feature.

@koalalorenzo
Copy link

Do we have any update? I know it might be redundant but I would love to get this merged! what can we do to help getting this merged? @mattfarina @jdolitsky any idea?

@jwenz723
Copy link

Would love to see this merged so that I can make use of helm charts published as releases in a private github repo.

@jverce
Copy link

jverce commented Mar 14, 2022

@mattfarina I think this is pending the resolution of a change you requested that's already been addressed, no?
If there's no more changes needed, can we have this merged?

PS: @lemonli this needs a rebase (it's been a while 😞)

@nkuzman
Copy link

nkuzman commented Apr 6, 2022

Any updates?
@lemonli seems to be inactive lately, can someone take over?

@ztbrown
Copy link

ztbrown commented Apr 11, 2022

#10848

Someone check to see if I did the rebase correctly?

@juldou
Copy link

juldou commented Aug 4, 2022

any updates?

@marcosnils
Copy link

dog-reading

@juldou
Copy link

juldou commented Aug 6, 2022

can someone check the rebase? #10848

@bmiag
Copy link

bmiag commented Aug 25, 2022

any news on this?

@edijsdrezovs
Copy link

Any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet