Pass credentials when either chart repo or repo dont specify a port but it matches the default port of that scheme

Signed-off-by: Danilo Bürger <danilo.buerger@helsing.ai>
pull/31057/head
Danilo Bürger 2 months ago
parent 091f9a24fe
commit 8096f09370
No known key found for this signature in database

@ -746,6 +746,21 @@ OUTER:
return nil
}
func portOrDefault(u *url.URL) string {
if p := u.Port(); p != "" {
return p
}
switch u.Scheme {
case "http":
return "80"
case "https":
return "443"
default:
return ""
}
}
// LocateChart looks for a chart directory in known places, and returns either the full path or an error.
//
// This does not ensure that the chart is well-formed; only that the requested filename exists.
@ -833,7 +848,7 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) (
// Host on URL (returned from url.Parse) contains the port if present.
// This check ensures credentials are not passed between different
// services on different ports.
if c.PassCredentialsAll || (u1.Scheme == u2.Scheme && u1.Host == u2.Host) {
if c.PassCredentialsAll || (u1.Scheme == u2.Scheme && u1.Hostname() == u2.Hostname() && portOrDefault(u1) == portOrDefault(u2)) {
dl.Options = append(dl.Options, getter.WithBasicAuth(c.Username, c.Password))
} else {
dl.Options = append(dl.Options, getter.WithBasicAuth("", ""))

Loading…
Cancel
Save