token

package
v0.0.0-...-36b6c77 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TokenEmitter

type TokenEmitter interface {
	Generate(id string) string
	Valid(token string, d time.Duration) (valid bool, id string, issue time.Time)
}

TokenEmitter interface to be able to generate and validate tokens

func NewTokenHmacSha

func NewTokenHmacSha(secret string) TokenEmitter

type TokenHmacSha

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

TokenHmacSha generate a tokes in the format <hash>.<rnd>.<id>.<ts> with hash = HMAC_SHA1 (secret, rnd + id + ts)

func (*TokenHmacSha) Generate

func (tk *TokenHmacSha) Generate(id string) string

func (*TokenHmacSha) Valid

func (tk *TokenHmacSha) Valid(token string, d time.Duration) (bool, string, time.Time)

Valid returns true if token is a valid and the Id associated with the token and the issue time

Jump to

Keyboard shortcuts

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