csrfmiddleware

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2016 License: MIT Imports: 6 Imported by: 0

README

CSRF (Cross Site Request Forgery) Protection Middleware

This middleware requires CleverGo CSRF and CleverGo Session Middleware.

This session middleware is necessary.

Install dependences

go get github.com/clevergo/sessions
go get github.com/clevergo/csrf

About the usages of sessions package, please refer to https://github.com/clevergo/sessions.

About the usages of csrf package, please refer to https://github.com/clevergo/csrf.

Example

CSRF Protection Example

go run $GOPATH/src/github.com/headwindfly/clevergo/examples/csrf/main.go

Usage

Please refer to JSON WEB TOKEN Example.

Set Error Handler

CSRFMiddleware.SetErrorHandler(handler clevergo.HandlerFunc)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSRFMiddleware

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

CSRFMiddleware Cross Site Request Forgery Protection Middleware.

func NewCSRFMiddleware

func NewCSRFMiddleware() CSRFMiddleware

NewCSRFMiddleware returns CSRF Middleware instance.

func (CSRFMiddleware) FormKey

func (m CSRFMiddleware) FormKey() string

FormKey returns formKey.

func (CSRFMiddleware) Handle

Handle implemented the Middleware Interface.

func (CSRFMiddleware) HeaderKey

func (m CSRFMiddleware) HeaderKey() string

HeaderKey returns headerKey.

func (CSRFMiddleware) Key

func (m CSRFMiddleware) Key() string

Key returns key.

func (CSRFMiddleware) Len

func (m CSRFMiddleware) Len() int

Len returns length of the CSRF token.

func (CSRFMiddleware) MaskLen

func (m CSRFMiddleware) MaskLen() int

MaskLen returns mask's length.

func (CSRFMiddleware) SessionKey

func (m CSRFMiddleware) SessionKey() string

SessionKey returns sessionKey.

func (*CSRFMiddleware) SetErrorHandler

func (m *CSRFMiddleware) SetErrorHandler(handler clevergo.HandlerFunc)

SetErrorHandler for setting error handler.

func (*CSRFMiddleware) SetFormKey

func (m *CSRFMiddleware) SetFormKey(key string)

SetFormKey for setting formKey.

func (*CSRFMiddleware) SetHeaderKey

func (m *CSRFMiddleware) SetHeaderKey(key string)

SetHeaderKey for setting headerKey.

func (*CSRFMiddleware) SetKey

func (m *CSRFMiddleware) SetKey(key string)

SetKey for setting key.

func (*CSRFMiddleware) SetLen

func (m *CSRFMiddleware) SetLen(len int)

SetLen for setting token's length.

func (*CSRFMiddleware) SetMaskLen

func (m *CSRFMiddleware) SetMaskLen(len int)

SetMaskLen for setting mask's length.

func (*CSRFMiddleware) SetSafeMethods

func (m *CSRFMiddleware) SetSafeMethods(methods []string)

SetSafeMethods for set safe methods.

func (*CSRFMiddleware) SetSessionKey

func (m *CSRFMiddleware) SetSessionKey(key string)

SetSessionKey for setting sessionKey.

Jump to

Keyboard shortcuts

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