handler

package
v0.0.0-...-6d37592 Latest Latest
Warning

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

Go to latest
Published: May 24, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidHeader returned from IsAuthorized if the Authorization
	// header is missing or doesn't prefix the token with "JWT" as the
	// authorization type.
	ErrInvalidHeader = errors.New("invalid authorization header")
)

Functions

func Authenticate

func Authenticate(out http.ResponseWriter, req *http.Request)

Authenticate the user and return a JSON Web Token.

func IsAuthorized

func IsAuthorized(req *http.Request) (model.User, error)

IsAuthorized pulls the token from the Authorization header and validates. Returns the user if valid (good signature, not expired), or an error if not.

func Ping

func Ping(out http.ResponseWriter, req *http.Request)

Ping is used to check that Engaged is active, typically by a load balancer.

func PublicKeys

func PublicKeys(out http.ResponseWriter, req *http.Request)

PublicKeys returns a map of key ID to public keys available on this server for confirming JWT tokens.

func Routes

func Routes() http.Handler

Routes configures a handler to route HTTP requests. Supports only a few endpoints such as the /v1/ping health check and /v1/keys to expose the public keys used to encrypt JSON web tokens.

func Sample

func Sample(out http.ResponseWriter, req *http.Request)

Sample is a sample secure API call. Returns the word "OK" followed by the user's name if the user is valid.

Put your token in the "Authorization" header, e.g.

Authorization: JWT <my token here>

func UpdateToken

func UpdateToken(out http.ResponseWriter, req *http.Request)

UpdateToken generates a new JSON Web Token with the expiration extended.

Types

This section is empty.

Jump to

Keyboard shortcuts

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