refererKit

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGinRefererMiddleware

func NewGinRefererMiddleware(builders []*RefererVerifierBuilder) (gin.HandlerFunc, error)

Types

type RefererVerifier

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

func (*RefererVerifier) Verify

func (verifier *RefererVerifier) Verify(route, referer string) (bool, string)

Verify 验证referer

@param route 请求的路由(可以通过 ctx.FullPath() 获取) @param referer 请求的referer(可能为"") @return 验证是否通过 + 验证失败的原因

func (*RefererVerifier) VerifyByGinContext

func (verifier *RefererVerifier) VerifyByGinContext(ctx *gin.Context) (bool, string)

VerifyByGinContext 验证referer

type RefererVerifierBuilder

type RefererVerifierBuilder struct {
	None    bool
	Blocked bool

	// Route 路由的正则字符串
	Route string
	// ServerNames referer白名单的正则字符串s
	ServerNames []string
}

func (*RefererVerifierBuilder) Build

func (builder *RefererVerifierBuilder) Build() (*RefererVerifier, error)

Jump to

Keyboard shortcuts

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