auth

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package auth provides authentication handlers for HTTP requests. It supports Basic, Digest, and AWS Signature v4 authentication schemes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDigestAuth

func BuildDigestAuth(username, password, method, uri string, challenge DigestChallenge) string

BuildDigestAuth builds the digest auth response header value

func DeleteAuthHeader

func DeleteAuthHeader(request *models.HttpRequest)

DeleteAuthHeader removes the Authorization header

func GenerateNonce

func GenerateNonce() string

GenerateNonce generates a random nonce for auth purposes

func UpdateAuthHeader

func UpdateAuthHeader(request *models.HttpRequest, value string)

UpdateAuthHeader updates or sets the Authorization header

Types

type AWSSigner

type AWSSigner struct {
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
	Region          string
	Service         string
}

AWSSigner implements AWS Signature v4

func (*AWSSigner) Sign

func (s *AWSSigner) Sign(request *models.HttpRequest) error

Sign signs the request with AWS Signature v4

type DigestChallenge

type DigestChallenge struct {
	Realm     string
	Nonce     string
	Opaque    string
	QOP       string
	Algorithm string
}

DigestChallenge holds parsed digest challenge from WWW-Authenticate header

func ParseDigestChallenge

func ParseDigestChallenge(header string) DigestChallenge

ParseDigestChallenge parses the WWW-Authenticate header for digest auth

type DigestCredentials

type DigestCredentials struct {
	Username string
	Password string
}

DigestCredentials stores digest auth credentials

type Processor

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

Processor handles authentication processing for HTTP requests

func NewProcessor

func NewProcessor() *Processor

NewProcessor creates a new authentication processor

func (*Processor) GetDigestCredentials

func (p *Processor) GetDigestCredentials(urlStr string) (DigestCredentials, bool)

GetDigestCredentials returns stored digest credentials for a URL

func (*Processor) ProcessAuth

func (p *Processor) ProcessAuth(request *models.HttpRequest) error

ProcessAuth processes authentication headers in the request It returns nil if no auth processing is needed or on success.

Jump to

Keyboard shortcuts

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