csrf

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2018 License: MIT Imports: 10 Imported by: 0

README

gin-csrf

Cookie-to-header csrf for gin with max usage feature. Using this package in conjunction with session. Cookie is only the transport.

Usage

router := gin.Default()
options := csrf.DefaultOptions()
options.MaxUsage = 10
options.MaxAge = 15 * 60
router.Use(csrf.Csrf(options))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Csrf

func Csrf(options *Options) gin.HandlerFunc

Csrf ...

Types

type Options

type Options struct {
	// maximum usage of csrf token
	MaxUsage int
	// maximum age for this token to live
	MaxAge int
	// name of the cookie to keep csrf token
	CookieName string
	// name of the header which the csrf token is sending back
	HeaderName string
	// for setting the cookie
	Secure bool
	// name for keeping usage counter in redis
	UsageCounterName string
	// name for keeping csrf token in redis session
	SessionName string
	// name for keeping issued time in redis
	IssuedName string
	// Length of csrf token
	ByteLenth int
	// path which the cookie is valid
	Path string
	// Http methods considered as safe and pass validation
	SafeMethods []string
}

func DefaultOptions

func DefaultOptions() *Options

Jump to

Keyboard shortcuts

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