Documentation ¶
Index ¶
- Variables
- func Authenticate(out http.ResponseWriter, req *http.Request)
- func IsAuthorized(req *http.Request) (model.User, error)
- func Ping(out http.ResponseWriter, req *http.Request)
- func PublicKeys(out http.ResponseWriter, req *http.Request)
- func Routes() http.Handler
- func Sample(out http.ResponseWriter, req *http.Request)
- func UpdateToken(out http.ResponseWriter, req *http.Request)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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.