token

package
v0.0.0-...-c6de284 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Hash        string // Hash of token. Don't store token itself
	User        string
	Role        easyauth.Role
	Description string
	LastUsed    time.Time
	RoleHash    string // Hash of token and Role for security purposes
}

type TokenDataAccess

type TokenDataAccess interface {
	LookupToken(hash string) (*Token, error)
	StoreToken(*Token) error
	RevokeToken(hash string) error
	ListTokens() ([]*Token, error)
}

func NewJsonStore

func NewJsonStore(fname string) (TokenDataAccess, error)

NewJsonStore makes a simple token store that keeps tokens in-memory, backed up to a local json file. Not suitable for high volume or high reliability. if you specify an empty string for file name, nothing will be backed up to disk, and you will have a solely in-memory store

type TokenProvider

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

func NewToken

func NewToken(secret string, data TokenDataAccess) *TokenProvider

func (*TokenProvider) AdminHandler

func (t *TokenProvider) AdminHandler() http.Handler

func (*TokenProvider) GetUser

func (t *TokenProvider) GetUser(r *http.Request) (*easyauth.User, error)

func (*TokenProvider) LoginHandler

func (t *TokenProvider) LoginHandler() http.Handler

func (*TokenProvider) NewToken

func (t *TokenProvider) NewToken(user, description string, role easyauth.Role) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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