Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportedAuthTypes ¶
func SupportedAuthTypes() []string
SupportedAuthTypes returns the supported auth types
Types ¶
type AuthFileInfo ¶
type AuthStrategy ¶
type AuthStrategy interface {
// Apply applies the strategy to the request
Apply(*http.Request)
// ApplyOnRR applies the strategy to the retryable request
ApplyOnRR(*retryablehttp.Request)
}
AuthStrategy is an interface for auth strategies basic auth , bearer token, headers, cookies, query
type Authx ¶
type Authx struct {
ID string `json:"id" yaml:"id"`
Info AuthFileInfo `json:"info" yaml:"info"`
Secrets []Secret `json:"static" yaml:"static"`
}
Authx is a struct for secrets or credentials file
func GetAuthDataFromFile ¶
GetAuthDataFromFile reads the auth data from file
func GetAuthDataFromJSON ¶
GetAuthDataFromJSON reads the auth data from json
func GetAuthDataFromYAML ¶
GetAuthDataFromYAML reads the auth data from yaml
type BasicAuthStrategy ¶
type BasicAuthStrategy struct {
Data *Secret
}
BasicAuthStrategy is a strategy for basic auth
func NewBasicAuthStrategy ¶
func NewBasicAuthStrategy(data *Secret) *BasicAuthStrategy
NewBasicAuthStrategy creates a new basic auth strategy
func (*BasicAuthStrategy) Apply ¶
func (s *BasicAuthStrategy) Apply(req *http.Request)
Apply applies the basic auth strategy to the request
func (*BasicAuthStrategy) ApplyOnRR ¶
func (s *BasicAuthStrategy) ApplyOnRR(req *retryablehttp.Request)
ApplyOnRR applies the basic auth strategy to the retryable request
type BearerTokenAuthStrategy ¶
type BearerTokenAuthStrategy struct {
Data *Secret
}
BearerTokenAuthStrategy is a strategy for bearer token auth
func NewBearerTokenAuthStrategy ¶
func NewBearerTokenAuthStrategy(data *Secret) *BearerTokenAuthStrategy
NewBearerTokenAuthStrategy creates a new bearer token auth strategy
func (*BearerTokenAuthStrategy) Apply ¶
func (s *BearerTokenAuthStrategy) Apply(req *http.Request)
Apply applies the bearer token auth strategy to the request
func (*BearerTokenAuthStrategy) ApplyOnRR ¶
func (s *BearerTokenAuthStrategy) ApplyOnRR(req *retryablehttp.Request)
ApplyOnRR applies the bearer token auth strategy to the retryable request
type Cookie ¶
type Cookie struct {
Key string `json:"key" yaml:"key"`
Value string `json:"value" yaml:"value"`
Raw string `json:"raw" yaml:"raw"`
}
type CookiesAuthStrategy ¶
type CookiesAuthStrategy struct {
Data *Secret
}
CookiesAuthStrategy is a strategy for cookies auth
func NewCookiesAuthStrategy ¶
func NewCookiesAuthStrategy(data *Secret) *CookiesAuthStrategy
NewCookiesAuthStrategy creates a new cookies auth strategy
func (*CookiesAuthStrategy) Apply ¶
func (s *CookiesAuthStrategy) Apply(req *http.Request)
Apply applies the cookies auth strategy to the request
func (*CookiesAuthStrategy) ApplyOnRR ¶
func (s *CookiesAuthStrategy) ApplyOnRR(req *retryablehttp.Request)
ApplyOnRR applies the cookies auth strategy to the retryable request
type HeadersAuthStrategy ¶
type HeadersAuthStrategy struct {
Data *Secret
}
HeadersAuthStrategy is a strategy for headers auth
func NewHeadersAuthStrategy ¶
func NewHeadersAuthStrategy(data *Secret) *HeadersAuthStrategy
NewHeadersAuthStrategy creates a new headers auth strategy
func (*HeadersAuthStrategy) Apply ¶
func (s *HeadersAuthStrategy) Apply(req *http.Request)
Apply applies the headers auth strategy to the request NOTE: This preserves exact header casing (e.g., barAuthToken stays as barAuthToken) This is useful for APIs that require case-sensitive header names
func (*HeadersAuthStrategy) ApplyOnRR ¶
func (s *HeadersAuthStrategy) ApplyOnRR(req *retryablehttp.Request)
ApplyOnRR applies the headers auth strategy to the retryable request NOTE: This preserves exact header casing (e.g., barAuthToken stays as barAuthToken) This is useful for APIs that require case-sensitive header names
type KV ¶
type QueryAuthStrategy ¶
type QueryAuthStrategy struct {
Data *Secret
}
QueryAuthStrategy is a strategy for query auth
func NewQueryAuthStrategy ¶
func NewQueryAuthStrategy(data *Secret) *QueryAuthStrategy
NewQueryAuthStrategy creates a new query auth strategy
func (*QueryAuthStrategy) Apply ¶
func (s *QueryAuthStrategy) Apply(req *http.Request)
Apply applies the query auth strategy to the request
func (*QueryAuthStrategy) ApplyOnRR ¶
func (s *QueryAuthStrategy) ApplyOnRR(req *retryablehttp.Request)
ApplyOnRR applies the query auth strategy to the retryable request
type Secret ¶
type Secret struct {
Type string `json:"type" yaml:"type"`
Domains []string `json:"domains" yaml:"domains"`
DomainsRegex []string `json:"domains-regex" yaml:"domains-regex"`
Headers []KV `json:"headers" yaml:"headers"` // Headers preserve exact casing (useful for case-sensitive APIs)
Cookies []Cookie `json:"cookies" yaml:"cookies"`
Params []KV `json:"params" yaml:"params"`
Username string `json:"username" yaml:"username"` // can be either email or username
Password string `json:"password" yaml:"password"`
Token string `json:"token" yaml:"token"` // Bearer Auth token
}
Secret is a struct for secret or credential
func (*Secret) GetStrategy ¶
func (s *Secret) GetStrategy() AuthStrategy
GetStrategy returns the auth strategy for the secret