token

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storer

type Storer interface {
	CreateActionToken(userID, tokenID, action string, expiry time.Time) (interface{}, error)
	GetActionToken(tokenID string) (interface{}, error)
	UpdateActionToken(token interface{}) (interface{}, error)
}

Storer defines the backing storage required by the token controller

type Token

type Token interface {
	GetTokenID() string
	GetUserExtID() string
	GetAction() string
	IsUsed() bool
	GetExpiry() time.Time
	SetUsed(t time.Time)
}

Token defines the interface required for stored tokens

type TokenClaims

type TokenClaims struct {
	Action api.TokenAction `json:"act"` // Token action
	jwt.StandardClaims
}

Custom claims object

type TokenController

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

TokenController instance

func NewTokenController

func NewTokenController(address string, hmacSecret string, storer Storer) *TokenController

NewTokenController constructor

func (*TokenController) BuildToken

func (tc *TokenController) BuildToken(userID string, action api.TokenAction, duration time.Duration) (string, error)

BuildToken builds a signed token for the given user id with a provided action and duration for use

func (*TokenController) SetUsed

func (tc *TokenController) SetUsed(tokenString string) error

SetUsed marks a token as used in the backing datastore

func (*TokenController) ValidateToken

func (tc *TokenController) ValidateToken(userID, tokenString string) (*api.TokenAction, error)

ValidateToken validates a token using the provided key and backing store

Jump to

Keyboard shortcuts

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