middleware

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: MIT Imports: 5 Imported by: 4

Documentation

Overview

Package middleware provides login middlewares: - Auth: adds auth from session and populates user info - Trace: populates user info if token presented - AdminOnly: restrict access to admin users only

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator struct {
	logger.L
	JWTService   TokenService
	Providers    []provider.Service
	Validator    token.Validator
	AdminPasswd  string
	RefreshCache RefreshCache
}

Authenticator is top level auth object providing middlewares

func (*Authenticator) AdminOnly

func (a *Authenticator) AdminOnly(next http.Handler) http.Handler

AdminOnly middleware allows access for admins only this handler internally wrapped with auth(true) to avoid situation if AdminOnly defined without prior Auth

func (*Authenticator) Auth

func (a *Authenticator) Auth(next http.Handler) http.Handler

Auth middleware adds auth from session and populates user info

func (*Authenticator) Trace

func (a *Authenticator) Trace(next http.Handler) http.Handler

Trace middleware doesn't require valid user but if user info presented populates info

type RefreshCache added in v0.4.0

type RefreshCache interface {
	Get(key interface{}) (value interface{}, ok bool)
	Set(key, value interface{})
}

type TokenService

type TokenService interface {
	Parse(tokenString string) (claims token.Claims, err error)
	Set(w http.ResponseWriter, claims token.Claims) (token.Claims, error)
	Get(r *http.Request) (claims token.Claims, token string, err error)
	IsExpired(claims token.Claims) bool
	Reset(w http.ResponseWriter)
}

TokenService defines interface accessing tokens

Jump to

Keyboard shortcuts

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