middleware

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: MIT Imports: 5 Imported by: 4

Documentation

Overview

Package middleware provides oauth2 support as well as related middlewares.

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
}

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 TokenService

type TokenService interface {
	Parse(tokenString string) (claims token.Claims, err error)
	Set(w http.ResponseWriter, 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