challenge

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ResultStop Stop testing other challenges and return
	ResultStop = Result(iota)
	// ResultContinue Test next
	ResultContinue
	// ResultPass  passed, return and proxy
	ResultPass
)
View Source
const (
	VerifyResultNONE = VerifyResult(iota)
	VerifyResultFAIL
	VerifyResultSKIP

	// VerifyResultPASS Client just passed this challenge
	VerifyResultPASS
	VerifyResultOK
	VerifyResultBRIEF
	VerifyResultFULL
)

Variables

View Source
var ErrVerifyKeyMismatch = errors.New("verify: key mismatch")
View Source
var ErrVerifyVerifyMismatch = errors.New("verify: verification mismatch")

Functions

This section is empty.

Types

type Challenge

type Challenge struct {
	Id      Id
	Program cel.Program
	Name    string
	Path    string

	Verify            func(key []byte, result string, r *http.Request) (bool, error)
	VerifyProbability float64

	ServeStatic http.Handler

	ServeChallenge func(w http.ResponseWriter, r *http.Request, key []byte, expiry time.Time) Result

	ServeScript     http.Handler
	ServeScriptPath string

	ServeMakeChallenge   http.Handler
	ServeVerifyChallenge http.Handler
}

func (Challenge) IssueChallengeToken

func (c Challenge) IssueChallengeToken(privateKey ed25519.PrivateKey, key, result []byte, until time.Time) (token string, err error)

func (Challenge) VerifyChallengeToken

func (c Challenge) VerifyChallengeToken(publicKey ed25519.PublicKey, expectedKey []byte, r *http.Request) (VerifyResult, error)

type Id

type Id int

type Result

type Result int

type Token

type Token struct {
	Name   string `json:"name"`
	Key    []byte `json:"key"`
	Result []byte `json:"result,omitempty"`

	Expiry    *jwt.NumericDate `json:"exp,omitempty"`
	NotBefore *jwt.NumericDate `json:"nbf,omitempty"`
	IssuedAt  *jwt.NumericDate `json:"iat,omitempty"`
}

type VerifyResult

type VerifyResult int

func (VerifyResult) Ok

func (r VerifyResult) Ok() bool

func (VerifyResult) String

func (r VerifyResult) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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