Path: blob/dev/pkg/authprovider/authx/strategy.go
2070 views
package authx12import (3"net/http"45"github.com/projectdiscovery/retryablehttp-go"6)78// AuthStrategy is an interface for auth strategies9// basic auth , bearer token, headers, cookies, query10type AuthStrategy interface {11// Apply applies the strategy to the request12Apply(*http.Request)13// ApplyOnRR applies the strategy to the retryable request14ApplyOnRR(*retryablehttp.Request)15}1617// DynamicAuthStrategy is an auth strategy for dynamic secrets18// it implements the AuthStrategy interface19type DynamicAuthStrategy struct {20// Dynamic is the dynamic secret to use21Dynamic Dynamic22}2324// Apply applies the strategy to the request25func (d *DynamicAuthStrategy) Apply(req *http.Request) {26strategies := d.Dynamic.GetStrategies()27if strategies == nil {28return29}30for _, s := range strategies {31if s == nil {32continue33}34s.Apply(req)35}36}3738// ApplyOnRR applies the strategy to the retryable request39func (d *DynamicAuthStrategy) ApplyOnRR(req *retryablehttp.Request) {40strategy := d.Dynamic.GetStrategies()41for _, s := range strategy {42s.ApplyOnRR(req)43}44}454647