jwtAuth

package module
v0.0.0-...-6a660fa Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2014 License: MIT Imports: 4 Imported by: 2

README

jwtAuth

GoDoc Build Status

Some simple Handlers and Helpers to use jwt-go for go http stuff.

Currently only RS256 is supported. If you have need/ideas for key schemes to use HS256, contact me or open a PR.

Working

  • MakeToken for creating signed tokens
  • VerifyHeader to check if a key is valid

TODO

  • Make simple Handler to resign a token (extend its valdity)
  • Tests MakeToken

How to get Keys

openssl genrsa -out app.rsa <keysize> # i'd suggest 4096
openssl rsa -in app.rsa -pubout > app.rsa.pub

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken     = errors.New("jwtAuth: Invalid Token")
	ErrVerifyFuncNotSet = errors.New("jwtAuth: You did not set VerifyFunc.")
)
View Source
var HeaderKey = "Authorization" // Default Header name
View Source
var VerifyFunc = func(tok *jwt.Token) (interface{}, error) {
	return nil, ErrVerifyFuncNotSet
}

you need to overwrite this to supply your key. you can make also make custom checks on the claim. claim[exp] is verified internaly by the jwt-go package

Functions

func MakeToken

func MakeToken(signKey interface{}, claims map[string]interface{}, validDur time.Duration) (string, error)

MakeToken creates a new RS256 signed token. it sets the claims map and usses validDur to sepcify when it is expireing from time.Now()

func VerifyHeader

func VerifyHeader(r *http.Request) (http.Header, error)

VerifyHeader checks for the exsistence of a Token in the Request Header it Verifies the Token using the user supplied VerifyFunc func signature is chosen to work with go-tigertonic.If()

Types

This section is empty.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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