oauth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	Router *router.Module

	HandleError func(http.ResponseWriter, *http.Request, error) error
	// contains filtered or unexported fields
}

Module oauth implements oauth start and callback

func (*Module) AddProvider

func (m *Module) AddProvider(p *Provider)

AddProvider adds a new provider to the oauth module. Provider are registered during the Start phase.

func (*Module) Init

func (m *Module) Init(c *service.Config)

Init this module.

type Provider

type Provider struct {
	// required
	Base         string
	Config       *oauth2.Config
	PostCallback RedirectCallbackFn

	// optional
	Options       []oauth2.AuthCodeOption
	SetOAuthState func(*http.Request, router.Params) (string, error)
	NewClient     func(context.Context, *oauth2.Token) *http.Client
	// contains filtered or unexported fields
}

Provider allows configuration of multiple oauth providers

func (*Provider) Client

func (p *Provider) Client(ctx context.Context, t *oauth2.Token) *http.Client

Client returns a new http client for authenticated requests. Provider can be configured with NewClient to override the default oauth2.Config.Client.

func (*Provider) HandleOAuthStart

func (p *Provider) HandleOAuthStart(rw http.ResponseWriter, req *http.Request, par router.Params) error

HandleOAuthStart is the handler for redirecting to the oauth provider.

type RedirectCallbackFn

type RedirectCallbackFn = func(*http.Request, http.ResponseWriter, *oauth2.Token, string) error

RedirectCallbackFn is the type of the callback after successfully handling the oauth callback token exchange.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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