authentication

package
v1.0.99 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenExpired = errors.New("token expired")
	ErrInvalidToken = errors.New("invalid token")
)
View Source
var OSEnvLookup = func(key string) (string, bool) {
	return os.LookupEnv(key)
}

OSEnvLookup is a function that looks up environment variables.

Functions

func AgentAuthenticationMiddleware added in v1.0.97

func AgentAuthenticationMiddleware(config []project.AgentConfig, lookup EnvLookupFunc, next http.HandlerFunc) http.HandlerFunc

AgentAuthenticationMiddleware returns HTTP middleware that authenticates agents.

func BuildAgentSecrets added in v1.0.97

func BuildAgentSecrets(agents []project.AgentConfig, lookup EnvLookupFunc) (map[string]cstr.MaskedString, error)

BuildAgentSecrets will build a map of secrets for the given agents based on their authentication type.

func InterpolateAgentConfig added in v1.0.97

func InterpolateAgentConfig(config []project.AgentConfig, lookup EnvLookupFunc) []project.AgentConfig

InterpolateAgentConfig interpolates environment variables in agent configurations and returns them as non-interpolated values replaced using the provided lookup function.

func NewBearerToken

func NewBearerToken(sharedSecret string, opts ...TokenOpt) (string, error)

NewBearerToken generates a new bearer token

func ValidateAgentAuthentication added in v1.0.97

func ValidateAgentAuthentication(config project.AgentConfig, lookup EnvLookupFunc, headers http.Header) bool

ValidateAgentAuthentication validates the authentication of an agent.

func ValidateToken

func ValidateToken(sharedSecret string, auth string) error

Types

type EnvLookupFunc added in v1.0.97

type EnvLookupFunc func(string) (string, bool)

type TokenOpt

type TokenOpt func(*tokenOpts) error

func WithExpiration

func WithExpiration(expiration time.Time) TokenOpt

func WithNonce deprecated

func WithNonce(nonce string) TokenOpt

WithNonce is a TokenOpt that sets the nonce for the token

Deprecated: it is better to pass no token and let the function generate a random token

Jump to

Keyboard shortcuts

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