auth

package
v1.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthExtract

type AuthExtract struct {
	Name       string `json:"name"`   // variable name to set
	Source     string `json:"source"` // "body", "header", "cookie", "json"
	Regex      string `json:"regex,omitempty"`
	JSONPath   string `json:"json_path,omitempty"`
	HeaderName string `json:"header_name,omitempty"`
	CookieName string `json:"cookie_name,omitempty"`
	// contains filtered or unexported fields
}

AuthExtract extracts values from a response for use in subsequent steps.

type AuthStep

type AuthStep struct {
	Method    string            `json:"method"`
	URL       string            `json:"url"`
	Headers   map[string]string `json:"headers,omitempty"`
	Body      string            `json:"body,omitempty"`
	Extract   []AuthExtract     `json:"extract,omitempty"`
	Condition string            `json:"condition,omitempty"` // HTTP status condition (e.g. "200", "302")
}

AuthStep is one step in the authentication flow.

type Authenticator

type Authenticator struct {
	// contains filtered or unexported fields
}

Authenticator manages authentication profiles and sessions.

func NewAuthenticator

func NewAuthenticator(client *http.Client) *Authenticator

NewAuthenticator creates an authenticator with an HTTP client.

func (*Authenticator) AddProfile

func (a *Authenticator) AddProfile(p *Profile)

AddProfile registers an auth profile for later use.

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(profileName string, vars map[string]string) (*Session, error)

Authenticate runs an auth profile and returns the resulting session. Variables like {{USER}} and {{PASS}} are substituted from the provided vars.

func (*Authenticator) AuthenticateProfile

func (a *Authenticator) AuthenticateProfile(p *Profile, vars map[string]string) (*Session, error)

AuthenticateProfile runs a profile directly (without pre-registration).

func (*Authenticator) LoadProfile

func (a *Authenticator) LoadProfile(r io.Reader) (*Profile, error)

LoadProfile parses a JSON auth profile definition.

func (*Authenticator) LoadProfileString

func (a *Authenticator) LoadProfileString(jsonStr string) (*Profile, error)

LoadProfileString parses a JSON snippet directly.

type Profile

type Profile struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Variables   map[string]string `json:"variables"` // {{USER}}, {{PASS}}, etc.
	Steps       []AuthStep        `json:"steps"`
}

Profile defines a multi-step authentication flow.

func BuiltinBearerToken

func BuiltinBearerToken(token string) *Profile

BuiltinBearerToken returns a profile that just sets a Bearer token header.

func BuiltinFormLogin

func BuiltinFormLogin(loginURL, username, password string) *Profile

BuiltinFormLogin returns a generic form-based login profile.

func BuiltinOAuth2ClientCredentials

func BuiltinOAuth2ClientCredentials(tokenURL, clientID, clientSecret string) *Profile

BuiltinOAuth2ClientCredentials returns an OAuth2 client_credentials profile.

type Session

type Session struct {
	ProfileName string
	Cookies     []*http.Cookie
	Headers     map[string]string
	Variables   map[string]string
	CookiesRaw  string // "Cookie" header format
	// contains filtered or unexported fields
}

Session holds the authenticated state after a profile completes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL