Path: blob/dev/pkg/authprovider/authx/bearer_auth.go
2070 views
package authx12import (3"net/http"45"github.com/projectdiscovery/retryablehttp-go"6)78var (9_ AuthStrategy = &BearerTokenAuthStrategy{}10)1112// BearerTokenAuthStrategy is a strategy for bearer token auth13type BearerTokenAuthStrategy struct {14Data *Secret15}1617// NewBearerTokenAuthStrategy creates a new bearer token auth strategy18func NewBearerTokenAuthStrategy(data *Secret) *BearerTokenAuthStrategy {19return &BearerTokenAuthStrategy{Data: data}20}2122// Apply applies the bearer token auth strategy to the request23func (s *BearerTokenAuthStrategy) Apply(req *http.Request) {24req.Header.Set("Authorization", "Bearer "+s.Data.Token)25}2627// ApplyOnRR applies the bearer token auth strategy to the retryable request28func (s *BearerTokenAuthStrategy) ApplyOnRR(req *retryablehttp.Request) {29req.Header.Set("Authorization", "Bearer "+s.Data.Token)30}313233