token

package
v0.0.0-...-52f8398 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Jwt

type Jwt struct {
	Provider Provider
	Key      []byte
}

Jwt jwt helper

func (*Jwt) New

func (p *Jwt) New(data map[string]interface{}, exp time.Duration) (string, error)

New generate token

func (*Jwt) Parse

func (p *Jwt) Parse(str string) (map[string]interface{}, error)

Parse parse token from string

func (*Jwt) ParseFromRequest

func (p *Jwt) ParseFromRequest(req *http.Request) (map[string]interface{}, error)

ParseFromRequest parse token from request

type Provider

type Provider interface {
	Set(kid string, key []byte, exp time.Duration) error
	Get(kid string) ([]byte, error)
	All() (map[string]int, error)
	Clear() error
}

Provider token provider

type RedisProvider

type RedisProvider struct {
	Redis *redis.Pool
}

RedisProvider redis token provider

func (*RedisProvider) All

func (p *RedisProvider) All() (map[string]int, error)

All list kids

func (*RedisProvider) Clear

func (p *RedisProvider) Clear() error

Clear clear kids

func (*RedisProvider) Get

func (p *RedisProvider) Get(kid string) ([]byte, error)

Get get key

func (*RedisProvider) Set

func (p *RedisProvider) Set(kid string, key []byte, exp time.Duration) error

Set set key

Jump to

Keyboard shortcuts

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