mod_secure_link

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReqWithoutExpiresKey   = fmt.Errorf("bad req: without expires key")
	ErrReqInvalidExpiresValue = fmt.Errorf("bad req: invalid expires val")
	ErrReqWithoutChecksumKey  = fmt.Errorf("bad req: without checksum key")
	ErrReqInvalidChecksum     = fmt.Errorf("bad req: invalid checksum key")
	ErrReqExpired             = fmt.Errorf("req overdue")
)

Functions

This section is empty.

Types

type Checker

type Checker struct {
	Config *CheckerConfig
	// contains filtered or unexported fields
}

func NewChecker

func NewChecker(cc *CheckerConfig) (*Checker, error)

NewChecker gen

func (*Checker) Check

func (cs *Checker) Check(request *bfe_basic.Request) error

Check validate request

type CheckerConfig

type CheckerConfig struct {
	ChecksumKey     string
	ExpiresKey      string
	ExpressionNodes []ExpressionNodeFile
}
type ConfModSecureLink struct {
	Basic struct {
		DataPath string // path of config data (mod_secure_link)
	}

	Log struct {
		OpenDebug bool
	}
}

func ConfLoad

func ConfLoad(filePath string, confRoot string) (*ConfModSecureLink, error)

type Data

type Data struct {
	Version string       // version of the config
	Config  ProductRules // product rules for header
}

func DataLoad

func DataLoad(filename string) (*Data, error)

DataLoad loads config of header from file.

func NewData

func NewData(cf *DataFile) (*Data, error)

type DataFile

type DataFile struct {
	Version *string // version of the config
	Config  ProductRulesFile
}

type Expression

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

func NewExpression

func NewExpression(cc *CheckerConfig) (*Expression, error)

func (*Expression) Value

func (exp *Expression) Value(req *bfe_basic.Request) string

type ExpressionNode

type ExpressionNode interface {
	Value(req *bfe_basic.Request) string
}

func NewNode

func NewNode(enf ExpressionNodeFile) (ExpressionNode, error)

type ExpressionNodeFile

type ExpressionNodeFile struct {
	Type  string
	Param string
}
type ModuleSecureLink struct {
	// contains filtered or unexported fields
}

ModuleSecureLink mean secure link module

func NewModuleSecureLink() *ModuleSecureLink

NewModuleSecureLink create module

func (*ModuleSecureLink) Init

Init init mode, will be invoked by framework

func (*ModuleSecureLink) Name

func (m *ModuleSecureLink) Name() string

Name return module name

type ModuleSecureLinkState

type ModuleSecureLinkState struct {
	ReqTotal  *metrics.Counter // all request in
	ReqAccept *metrics.Counter // request accept

	ReqWithoutExpiresKey   *metrics.Counter
	ReqInvalidExpiresValue *metrics.Counter
	ReqWithoutChecksumKey  *metrics.Counter
	ReqInvalidChecksum     *metrics.Counter
	ReqExpired             *metrics.Counter
}

type NodeConfig

type NodeConfig struct {
	ChecksumKey string
	ExpiresKey  string
	Expr        string
}

type ProductRules

type ProductRules map[string][]*Rule

type ProductRulesFile

type ProductRulesFile map[string][]*RuleFile

type Rule

type Rule struct {
	Cond condition.Condition // condition for header

	ChecksumKey string
	ExpiresKey  string

	Expression *Expression

	Checker *Checker
}

func NewRule

func NewRule(rf *RuleFile) (*Rule, error)

NewRule get Rule by RuleFile

func (*Rule) Check

func (rule *Rule) Check(req *bfe_basic.Request) error

type RuleFile

type RuleFile struct {
	Cond *string

	ChecksumKey     *string
	ExpiresKey      *string
	ExpressionNodes []ExpressionNodeFile
}

RuleFile define how to validate secure link

type SecureLinkTable

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

func NewSecureLinkTable

func NewSecureLinkTable() *SecureLinkTable

func (*SecureLinkTable) Search

func (t *SecureLinkTable) Search(product string) ([]*Rule, bool)

func (*SecureLinkTable) Update

func (t *SecureLinkTable) Update(conf *Data)

Jump to

Keyboard shortcuts

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