Skip to content

Commit

Permalink
fix secrets lookup logic (#6059)
Browse files Browse the repository at this point in the history
* fix secrets lookup logic

* check len
  • Loading branch information
dogancanbakir authored Feb 20, 2025
1 parent 89c77d1 commit cbd90df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pkg/authprovider/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func (f *FileAuthProvider) init() {

// LookupAddr looks up a given domain/address and returns appropriate auth strategy
func (f *FileAuthProvider) LookupAddr(addr string) []authx.AuthStrategy {
var strategies []authx.AuthStrategy

if strings.Contains(addr, ":") {
// default normalization for host:port
host, port, err := net.SplitHostPort(addr)
Expand All @@ -131,15 +133,16 @@ func (f *FileAuthProvider) LookupAddr(addr string) []authx.AuthStrategy {
}
for domain, strategy := range f.domains {
if strings.EqualFold(domain, addr) {
return strategy
strategies = append(strategies, strategy...)
}
}
for compiled, strategy := range f.compiled {
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
Expand Down
2 changes: 1 addition & 1 deletion pkg/authprovider/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewMultiAuthProvider(providers ...AuthProvider) AuthProvider {
func (m *MultiAuthProvider) LookupAddr(host string) []authx.AuthStrategy {
for _, provider := range m.Providers {
strategy := provider.LookupAddr(host)
if strategy != nil {
if len(strategy) > 0 {
return strategy
}
}
Expand Down

0 comments on commit cbd90df

Please sign in to comment.