Files
Doğan Can Bakır 62eed15d6d fix: address CodeRabbitAI review comments
- Fix slices.Delete while iterating bug in cookies_auth.go
- Fix Cookie.Parse to handle '=' chars in values using SplitN
- Add case-insensitive file extension handling in GetAuthDataFromFile
- Remove unreachable default case in Secret.Validate
- Make LookupURL/LookupURLX consistent with LookupAddr (use len>0)
- Improve comments for clarity

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 14:31:40 +03:00

51 lines
1.2 KiB
Go

package authprovider
import (
"net/url"
"github.com/projectdiscovery/httpx/common/authprovider/authx"
urlutil "github.com/projectdiscovery/utils/url"
)
// MultiAuthProvider is a convenience wrapper for multiple auth providers
// it returns the first matching auth strategy for a given domain
// if there are multiple auth strategies for a given domain, it returns the first one
type MultiAuthProvider struct {
Providers []AuthProvider
}
// NewMultiAuthProvider creates a new multi auth provider
func NewMultiAuthProvider(providers ...AuthProvider) AuthProvider {
return &MultiAuthProvider{Providers: providers}
}
func (m *MultiAuthProvider) LookupAddr(host string) []authx.AuthStrategy {
for _, provider := range m.Providers {
strategy := provider.LookupAddr(host)
if len(strategy) > 0 {
return strategy
}
}
return nil
}
func (m *MultiAuthProvider) LookupURL(u *url.URL) []authx.AuthStrategy {
for _, provider := range m.Providers {
strategy := provider.LookupURL(u)
if len(strategy) > 0 {
return strategy
}
}
return nil
}
func (m *MultiAuthProvider) LookupURLX(u *urlutil.URL) []authx.AuthStrategy {
for _, provider := range m.Providers {
strategy := provider.LookupURLX(u)
if len(strategy) > 0 {
return strategy
}
}
return nil
}