token

package
v0.0.0-...-9066a5a Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBase64Handler

func NewBase64Handler() base64Handler

func NewRedisHandler

func NewRedisHandler() *redisHandler

Types

type Handler

type Handler interface {
	Encrypt(SubscriptionData) (Token, error)
	Decrypt(Token) (SubscriptionData, error)
}

Handler converts between SuscriptionData and Token

type KeyValueStore

type KeyValueStore interface {
	Set(key string, value []byte) error
	Get(key string) ([]byte, error)
}

type MemoryHandler

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

func NewMemoryHandler

func NewMemoryHandler() *MemoryHandler

func (*MemoryHandler) Decrypt

func (h *MemoryHandler) Decrypt(t Token) (SubscriptionData, error)

func (*MemoryHandler) Encrypt

func (h *MemoryHandler) Encrypt(sd SubscriptionData) (Token, error)

type StringToken

type StringToken struct {
	Token string
}

StringToken represents the Token as a string

func (StringToken) String

func (s StringToken) String() string

type SubscriptionData

type SubscriptionData struct {
	UserId    string
	ExpiresAt time.Time
	Level     string
	Platform  string
}

SubscriptionData represents the data for a single user subscription

func (SubscriptionData) Equal

Equal returns true if a two instances of SubscriptionData are equal to each other It is necessary due to the fact that ExpiresAt cannot be reliably compared with ==

type Token

type Token interface {
	String() string
}

Token represents a token issued to the user

Jump to

Keyboard shortcuts

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