token

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateHandler added in v1.4.0

func GenerateHandler(m *Manager, tokenPassword string) func(w http.ResponseWriter, r *http.Request)

GenerateHandler will return a http handler to generate tokens.

func InspectHandler added in v1.4.0

func InspectHandler(m *Manager) func(w http.ResponseWriter, r *http.Request)

InspectHandler handles requests to see remaining credits for a token.

func ValidatedHandler

func ValidatedHandler(m *Manager, handler func(w http.ResponseWriter, r *http.Request, token *jwt.Token)) func(w http.ResponseWriter, r *http.Request)

ValidatedHandler will return a http handler which validates a request prior to invoking the given handler.

Types

type Generator

type Generator interface {
	Generate(subject string, claims jwt.MapClaims) (*jwt.Token, error)
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager validates and generates new tokens

func NewManager

func NewManager(pub, priv string) (*Manager, error)

func (*Manager) Generate

func (tm *Manager) Generate(subject string, claims jwt.MapClaims) (string, error)

Generate creates a token string.

func (*Manager) Validate

func (tm *Manager) Validate(token string) (*jwt.Token, error)

Validate should be called to validate a jwt token.

type TokenReply added in v1.4.0

type TokenReply struct {
	Token   string `json:"token"`
	Email   string `json:"email"`
	Credits int    `json:"credits"`
}

Token is used to create a JSON object.

Jump to

Keyboard shortcuts

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