token-auth: Index | Files | Directories

package tauth

import ""


Package Files


func DefaultUnauthorizedHandler Uses

func DefaultUnauthorizedHandler(w http.ResponseWriter, req *http.Request)

type BearerGetter Uses

type BearerGetter struct{}

func (*BearerGetter) GetTokenFromRequest Uses

func (b *BearerGetter) GetTokenFromRequest(req *http.Request) string

type ClaimGetter Uses

type ClaimGetter interface {
    Claims(string) interface{}

type ClaimSetter Uses

type ClaimSetter interface {
    SetClaim(string, interface{}) ClaimSetter

type QueryStringTokenGetter Uses

type QueryStringTokenGetter struct {
    Parameter string

func NewQueryStringTokenGetter Uses

func NewQueryStringTokenGetter(parameter string) *QueryStringTokenGetter

func (QueryStringTokenGetter) GetTokenFromRequest Uses

func (q QueryStringTokenGetter) GetTokenFromRequest(req *http.Request) string

type Token Uses

type Token interface {
    IsExpired() bool

func Get Uses

func Get(req *http.Request) Token

type TokenAuth Uses

type TokenAuth struct {
    UnauthorizedHandler http.HandlerFunc
    // contains filtered or unexported fields

func NewTokenAuth Uses

func NewTokenAuth(handler http.Handler, unauthorizedHandler http.HandlerFunc, store TokenStore, getter TokenGetter) *TokenAuth

Returns a TokenAuth object implemting Handler interface

if a handler is given it proxies the request to the handler

if a unauthorizedHandler is provided, unauthorized requests will be handled by this HandlerFunc, otherwise a default unauthorized handler is used.

store is the TokenStore that stores and verify the tokens

func (*TokenAuth) Authenticate Uses

func (t *TokenAuth) Authenticate(req *http.Request) (Token, error)

func (*TokenAuth) HandleFunc Uses

func (t *TokenAuth) HandleFunc(handlerFunc http.HandlerFunc) http.HandlerFunc

wrap a HandlerFunc to be authenticated

func (*TokenAuth) ServeHTTP Uses

func (t *TokenAuth) ServeHTTP(w http.ResponseWriter, req *http.Request)

implement Handler

type TokenGetter Uses

type TokenGetter interface {
    GetTokenFromRequest(req *http.Request) string

type TokenStore Uses

type TokenStore interface {
    CheckToken(token string) (Token, error)



Package tauth imports 5 packages (graph) and is imported by 5 packages. Updated 2016-07-16. Refresh now. Tools for package owners.