oauth2

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package oauth2 provides oauth2 middleware

Index

Constants

View Source
const OAuth2LoggerKey = "web.middleware.oauth2"

Variables

View Source
var ErrSessionNotInitialized = fmt.Errorf("session is not initialized in the context")

ErrSessionNotInitialized is an error if the session middleware is not initialized.

Functions

func FromContext

func FromContext(ctx context.Context) *oauth2.Token

Types

type Config

type Config interface {
	AuthCodeURL(string, ...oauth2.AuthCodeOption) string
	Exchange(context.Context, string) (*oauth2.Token, error)
}

Config is an interface for OAuth2 configuration. Use "golang.org/x/oauth2.Config"

type Middleware

type Middleware struct {
	AuthPath        string // path that redirects to oauth2 provider
	CallbackPath    string
	AuthCodeOptions []oauth2.AuthCodeOption
	Store           StateStore
	Config          Config
}

func NewMiddleware

func NewMiddleware() *Middleware

func (*Middleware) Process

func (m *Middleware) Process(req *web.Request, next web.NextHandler) *response.Response

type SessionStateStore

type SessionStateStore struct {
}

SessionStateStore is an implementation of StateStore using session.

func (*SessionStateStore) Get

Get implements StateStore#Get

func (*SessionStateStore) Set

func (*SessionStateStore) Set(ctx context.Context, state string) error

Set implements StateStore#Set

type StateStore

type StateStore interface {
	Set(context.Context, string) error
	Get(context.Context) (string, error)
}

StateStore is an interface for session storage.

Jump to

Keyboard shortcuts

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