fix secrets lookup logic (#6059)

* fix secrets lookup logic

* check len
This commit is contained in:
Dogan Can Bakir 2025-02-20 03:31:24 +03:00 committed by GitHub
parent 89c77d1e9e
commit cbd90df51c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View File

@ -122,6 +122,8 @@ func (f *FileAuthProvider) init() {
// LookupAddr looks up a given domain/address and returns appropriate auth strategy // LookupAddr looks up a given domain/address and returns appropriate auth strategy
func (f *FileAuthProvider) LookupAddr(addr string) []authx.AuthStrategy { func (f *FileAuthProvider) LookupAddr(addr string) []authx.AuthStrategy {
var strategies []authx.AuthStrategy
if strings.Contains(addr, ":") { if strings.Contains(addr, ":") {
// default normalization for host:port // default normalization for host:port
host, port, err := net.SplitHostPort(addr) host, port, err := net.SplitHostPort(addr)
@ -131,15 +133,16 @@ func (f *FileAuthProvider) LookupAddr(addr string) []authx.AuthStrategy {
} }
for domain, strategy := range f.domains { for domain, strategy := range f.domains {
if strings.EqualFold(domain, addr) { if strings.EqualFold(domain, addr) {
return strategy strategies = append(strategies, strategy...)
} }
} }
for compiled, strategy := range f.compiled { for compiled, strategy := range f.compiled {
if compiled.MatchString(addr) { if compiled.MatchString(addr) {
return strategy strategies = append(strategies, strategy...)
} }
} }
return nil
return strategies
} }
// LookupURL looks up a given URL and returns appropriate auth strategy // LookupURL looks up a given URL and returns appropriate auth strategy

View File

@ -22,7 +22,7 @@ func NewMultiAuthProvider(providers ...AuthProvider) AuthProvider {
func (m *MultiAuthProvider) LookupAddr(host string) []authx.AuthStrategy { func (m *MultiAuthProvider) LookupAddr(host string) []authx.AuthStrategy {
for _, provider := range m.Providers { for _, provider := range m.Providers {
strategy := provider.LookupAddr(host) strategy := provider.LookupAddr(host)
if strategy != nil { if len(strategy) > 0 {
return strategy return strategy
} }
} }