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 `json:"none" yaml:"none"` Blocked bool `json:"blocked" yaml:"blocked"` // Route 路由的正则字符串 Route string `json:"route" yaml:"route"` // ServerNames referer白名单的正则字符串s ServerNames []string `json:"serverNames" yaml:"serverNames"` }
func (*RefererVerifierBuilder) Build ¶
func (builder *RefererVerifierBuilder) Build() (*RefererVerifier, error)
Click to show internal directories.
Click to hide internal directories.