ac

package
v0.0.0-...-8fa2440 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ac provides facilities for generating and verifying anti-CSRF authentication codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAK

func GetAK(req *http.Request) []byte

Get the action key to use in relation to a given request.

func IsSafeMethod

func IsSafeMethod(methodName string) bool

func New

func New(req *http.Request, action string) string

Generate an action code for the given action in relation to a given request.

func NewFor

func NewFor(action string, ak []byte) string

Generate a nondeterministic action code using the given action name and action key.

func Protect

func Protect(f func(rw http.ResponseWriter, req *http.Request)) http.Handler

http.Handler wrapper that bails if a valid action key for the request URL's path is not found in GET/POST variable "ac".

func Protectn

func Protectn(fieldName string, f func(rw http.ResponseWriter, req *http.Request)) http.Handler

http.Handler wrapper that bails if a valid action key for the request URL's path is not found in the GET/POST variable whose name is specified in fieldName.

func Verify

func Verify(req *http.Request, ac string) bool

Verify an action code in relation to a given request. The action is the path of the request URL. Returns true iff valid.

func VerifyFor

func VerifyFor(action, ac string, ak []byte) bool

Verify an action code for the given action and action key. Returns true iff valid.

func VerifyStr

func VerifyStr(req *http.Request, action, ac string) bool

Verify an action code for the given action in relation to a given request. Returns true iff valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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