jwt

package
v0.0.0-...-237ae9d Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenExpired    = errors.New("Token Expired, get a new one")
	ErrTokenValidation = errors.New("JWT Token ValidationError")
	ErrTokenParse      = errors.New("JWT Token Error Parsing the token or empty token")
	ErrTokenInvalid    = errors.New("JWT Token is not Valid")
)

Functions

func GenerateJWTToken

func GenerateJWTToken(userId string, op Options) (string, error)

Generates a JSON Web Token given an userId (typically an id or an email), and the JWT options to set SigningMethod and the keys you can check http://github.com/dgrijalva/jwt-go

In case you use an symmetric-key algorithm set PublicKey and PrivateKey equal to the SecretKey ,

func ValidateToken

func ValidateToken(r *http.Request, publicKey string) (string, string, error)

Validates the token that is passed in the request with the Authorization header Authorization: Bearer eyJhbGciOiJub25lIn0

Returns the userId, token (base64 encoded), error

Types

type Options

type Options struct {
	SigningMethod string
	PublicKey     string
	PrivateKey    string
	Expiration    time.Duration
}

Jump to

Keyboard shortcuts

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