Documentation ¶
Index ¶
Constants ¶
View Source
const ( TokenSignerName = "tokenSign" HMACSignerName = "hmacSign" SignerName = "sign" )
Variables ¶
This section is empty.
Functions ¶
func Signature ¶
func Signature() handler.Middleware
Signature is the replay attack protect middleware apply function. See MiddlewareNewFunc
func TokenSigner ¶
func TokenSigner() handler.Middleware
Types ¶
type Config ¶
type Config struct { // Skipper defines a function to skip middleware. Skipper handler.Skipper `json:"-" yaml:"-"` // Exclude is a list of http paths to exclude from RAP Exclude []string `json:"exclude" yaml:"exclude"` SignerConfig httpx.SignerConfig `json:"signerConfig" yaml:"signerConfig"` // Interval is the interval time for request timestamp. // When default cache effect, this value is used by setting cache ttl. Interval time.Duration `json:"interval" yaml:"interval"` // StoreKey is the name of the cache driver which is used to store nonce. // default is "redis". StoreKey string `json:"storeKey" yaml:"storeKey"` // TTL is the ttl of signature. Must be greater than Interval. // // If you Use TokenSigner should be greater than the token ttl, in token ttl, the signature is cached, // so that the same request will be rejected. // Default is 24 hours. But when you use default cache, This value is not used. TTL time.Duration `json:"ttl" yaml:"ttl"` // NowFunc create a time.Time object for current time, useful in tests. NowFunc func() time.Time `json:"-" yaml:"-"` }
Config is the configuration for the Replay Attack Protect middleware.
type Middleware ¶
Middleware verifies signed http request, use it for replay attack protection and data tampering prevention.
If you don't set the cache, the middleware will use a default cache.
func NewMiddleware ¶
func NewMiddleware(name string, opts ...handler.MiddlewareOption) *Middleware
NewMiddleware constructs a new Middleware struct with supplied options. name is the name of the middleware, default is "sign", name can be empty string meaning default.
func (*Middleware) ApplyFunc ¶
func (mw *Middleware) ApplyFunc(cfg *conf.Configuration) gin.HandlerFunc
ApplyFunc applies the middleware to the gin engine.
func (*Middleware) Name ¶
func (mw *Middleware) Name() string
Click to show internal directories.
Click to hide internal directories.