token

package
v0.0.0-...-0f02880 Latest Latest
Warning

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

Go to latest
Published: May 30, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserToken is the prefix for the user session
	UserToken = "user"
	//SessToken is use for the cookie session name
	SessToken = "sess"
	// HookToken not sure
	HookToken = "hook"
	// CsrfToken is used for the csrf header prefix
	CsrfToken = "csrf"
)
View Source
const SignerAlgo = "HS256"

SignerAlgo default algorithm used to sign JWT tokens.

Variables

This section is empty.

Functions

func CheckCsrf

func CheckCsrf(r *http.Request, fn SecretFunc) error

CheckCsrf will return an error is the csrf token is not valite or malformed

Types

type SecretFunc

type SecretFunc func(*Token) (string, error)

SecretFunc type

type Token

type Token struct {
	Kind string
	Text string
	User *model.User
}

Token holds basic token information

func New

func New(kind, text string, user *model.User) *Token

New will return a new token struct

func Parse

func Parse(raw string, fn SecretFunc) (*Token, error)

Parse is used to pull session information from a raw string

func ParseRequest

func ParseRequest(r *http.Request, fn SecretFunc) (*Token, error)

ParseRequest is used to pull session information from a gin request

func (*Token) Sign

func (t *Token) Sign(secret string) (string, error)

Sign signs the token using the given secret hash and returns the string value.

func (*Token) SignExpires

func (t *Token) SignExpires(secret string, exp int64) (string, error)

SignExpires signs the token using the given secret hash with an expiration date.

Jump to

Keyboard shortcuts

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