middleware

package
v0.0.0-...-7cfd609 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonServerMiddlewares

func CommonServerMiddlewares(logger log.Logger) []middleware.Middleware

Types

type ChallengeResponse

type ChallengeResponse struct {
	ChallengeID string `json:"challenge_id"`
	Challenge   string `json:"challenge"`
	Difficulty  int    `json:"difficulty"`
}

ChallengeResponse 获取 challenge 的响应

type EdgeOne

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

EdgeOne EdgeOne 鉴权中间件

func NewEdgeOne

func NewEdgeOne(config *EdgeOneConfig) *EdgeOne

NewEdgeOne 创建 EdgeOne 鉴权实例

func (*EdgeOne) GenerateAppSignature

func (e *EdgeOne) GenerateAppSignature(path string) (string, string, string, string)

GenerateAppSignature 生成 APP 签名(用于测试)

func (*EdgeOne) GenerateWebSignature

func (e *EdgeOne) GenerateWebSignature(path string) (string, string, string, string)

GenerateWebSignature 生成 Web 签名(用于测试)

func (*EdgeOne) Server

func (e *EdgeOne) Server() middleware.Middleware

Server EdgeOne 鉴权中间件(用于源站验证,主要用于备用端点)

type EdgeOneConfig

type EdgeOneConfig struct {
	AppKey      string   // APP 密钥
	AppTokenP   string   // APP 签名参数名
	AppTsP      string   // APP 时间戳参数名
	AppTTL      int64    // APP 有效时长(秒)
	WebKey      string   // Web 密钥
	WebTokenP   string   // Web 签名参数名
	WebTsP      string   // Web 时间戳参数名
	WebTTL      int64    // Web 有效时长(秒)
	Enabled     bool     // 是否启用鉴权
	ExemptPaths []string // 豁免路径
}

EdgeOneConfig EdgeOne 鉴权配置

type PoW

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

PoWChallenge PoW 组件

func NewPoW

func NewPoW(config *PoWConfig) *PoW

NewPoW 创建 PoW 实例

func (*PoW) CalculateNonce

func (p *PoW) CalculateNonce(challenge string, difficulty int) string

CalculateNonce 计算 nonce(用于测试)

func (*PoW) GenerateChallenge

func (p *PoW) GenerateChallenge() *ChallengeResponse

GenerateChallenge 生成 challenge

func (*PoW) Server

func (p *PoW) Server() middleware.Middleware

Server PoW 中间件

func (*PoW) VerifyPoW

func (p *PoW) VerifyPoW(challengeID, nonce string) error

VerifyPoW 验证 PoW

type PoWConfig

type PoWConfig struct {
	Enabled      bool   // 是否启用 PoW
	Mode         string // enforce | log | off
	Difficulty   int    // 难度(前 N 位为 0
	ChallengeTTL int64  // challenge 有效期(秒)
}

PoWConfig PoW 配置

Jump to

Keyboard shortcuts

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