package authprovider12import (3"fmt"4"net/url"56"github.com/projectdiscovery/nuclei/v3/pkg/authprovider/authx"7urlutil "github.com/projectdiscovery/utils/url"8)910var (11ErrNoSecrets = fmt.Errorf("no secrets in given provider")12)1314var (15_ AuthProvider = &FileAuthProvider{}16)1718// AuthProvider is an interface for auth providers19// It implements a data structure suitable for quick lookup and retrieval20// of auth strategies21type AuthProvider interface {22// LookupAddr looks up a given domain/address and returns appropriate auth strategy23// for it (accepted inputs are scanme.sh or scanme.sh:443)24LookupAddr(string) []authx.AuthStrategy25// LookupURL looks up a given URL and returns appropriate auth strategy26// it accepts a valid url struct and returns the auth strategy27LookupURL(*url.URL) []authx.AuthStrategy28// LookupURLX looks up a given URL and returns appropriate auth strategy29// it accepts pd url struct (i.e urlutil.URL) and returns the auth strategy30LookupURLX(*urlutil.URL) []authx.AuthStrategy31// GetTemplatePaths returns the template path for the auth provider32// that will be used for dynamic secret fetching33GetTemplatePaths() []string34// PreFetchSecrets pre-fetches the secrets from the auth provider35// instead of lazy fetching36PreFetchSecrets() error37}3839// AuthProviderOptions contains options for the auth provider40type AuthProviderOptions struct {41// File based auth provider options42SecretsFiles []string43// LazyFetchSecret is a callback for lazy fetching of dynamic secrets44LazyFetchSecret authx.LazyFetchSecret45}4647// NewAuthProvider creates a new auth provider from the given options48func NewAuthProvider(options *AuthProviderOptions) (AuthProvider, error) {49var providers []AuthProvider50for _, file := range options.SecretsFiles {51provider, err := NewFileAuthProvider(file, options.LazyFetchSecret)52if err != nil {53return nil, err54}55providers = append(providers, provider)56}57return NewMultiAuthProvider(providers...), nil58}596061