action

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChallengeDefaultSettings = ChallengeSettings{
	PassAction: string(policy.RuleActionPASS),
	FailAction: string(policy.RuleActionDENY),
}
View Source
var CodeDefaultSettings = CodeSettings{}
View Source
var ContextDefaultSettings = ContextSettings{}
View Source
var ProxyDefaultSettings = ProxySettings{}
View Source
var Register = make(map[policy.RuleAction]NewFunc)

Functions

This section is empty.

Types

type Block

type Block struct {
	Code     int
	RuleHash string
}

func (Block) Handle

func (a Block) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type Challenge

type Challenge struct {
	RuleHash   string
	Code       int
	Continue   bool
	Challenges []*challenge.Registration

	PassAction        policy.RuleAction
	PassActionHandler Handler
	FailAction        policy.RuleAction
	FailActionHandler Handler
}

func (Challenge) Handle

func (a Challenge) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type ChallengeSettings

type ChallengeSettings struct {
	Code       int      `yaml:"http-code"`
	Challenges []string `yaml:"challenges"`

	PassAction   string   `yaml:"pass"`
	PassSettings ast.Node `yaml:"pass-settings"`

	// FailAction Executed in case no challenges match or
	FailAction   string   `yaml:"fail"`
	FailSettings ast.Node `yaml:"fail-settings"`
}

type Code

type Code int

func (Code) Handle

func (a Code) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type CodeSettings

type CodeSettings struct {
	Code int `yaml:"http-code"`
}

type Context added in v0.7.0

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

func (Context) Handle added in v0.7.0

func (a Context) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type ContextSettings added in v0.7.0

type ContextSettings struct {
	ContextSet      map[string]string   `yaml:"context-set"`
	ResponseHeaders map[string][]string `yaml:"response-headers"`
	RequestHeaders  map[string][]string `yaml:"request-headers"`
}

type Deny

type Deny struct {
	Code     int
	RuleHash string
}

func (Deny) Handle

func (a Deny) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type Drop

type Drop struct {
}

func (Drop) Handle

func (a Drop) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type Handler

type Handler interface {
	// Handle An incoming request.
	// If next is true, continue processing
	// If next is false, stop processing. If passing to a backend, done() must be called beforehand to set headers.
	Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)
}

type NewFunc

type NewFunc func(state challenge.StateInterface, ruleName, ruleHash string, settings ast.Node) (Handler, error)

type None

type None struct{}

func (None) Handle

func (a None) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type Pass

type Pass struct{}

func (Pass) Handle

func (a Pass) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type Proxy

type Proxy struct {
	Match   *regexp.Regexp
	Rewrite string
	Backend string
}

func (Proxy) Handle

func (a Proxy) Handle(logger *slog.Logger, w http.ResponseWriter, r *http.Request, done func() (backend http.Handler)) (next bool, err error)

type ProxySettings

type ProxySettings struct {
	Match   string `yaml:"proxy-match"`
	Rewrite string `yaml:"proxy-rewrite"`
	Backend string `yaml:"proxy-backend"`
}

Jump to

Keyboard shortcuts

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