oauth2

package
v0.0.0-...-07e1512 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: BSD-2-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BotMiddleware

type BotMiddleware struct {
	*oauth2.Config
	// contains filtered or unexported fields
}

BotMiddleware is a middleware implementing OAuth 2 authorization flows targeted at authorizing bots.

func NewBotMiddleware

func NewBotMiddleware(tc *tls.Config) *BotMiddleware

NewBotMiddleware returns a new bot middleware instance.

func (*BotMiddleware) Callback

func (m *BotMiddleware) Callback(w http.ResponseWriter, r *http.Request)

Callback is an endpoint that can be used as a redirect URI target in an OAuth 2 authorization flow targeted at bots.

func (*BotMiddleware) Invite

func (m *BotMiddleware) Invite(w http.ResponseWriter, r *http.Request)

Invite starts a new OAuth 2 bot authorization flow.

func (*BotMiddleware) Prechecker

func (m *BotMiddleware) Prechecker(next http.Handler) http.Handler

Prechecker checks that middleware is in a valid state for OAuth 2 authorization flow execution. In other words, it checks that session values can be obtained from session stores.

type UserMiddleware

type UserMiddleware struct {
	*oauth2.Config
	// contains filtered or unexported fields
}

UserMiddleware is a middleware implementing OAuth 2 authorization flows targeted at authorizing users.

func NewUserMiddleware

func NewUserMiddleware(tc *tls.Config) *UserMiddleware

NewUserMiddleware returns a new user middleware instance.

func (*UserMiddleware) Callback

func (m *UserMiddleware) Callback(w http.ResponseWriter, r *http.Request)

Callback is an endpoint that can be used as a redirect URI target in an OAuth 2 authorization flow targeted at users.

func (*UserMiddleware) Login

func (m *UserMiddleware) Login(w http.ResponseWriter, r *http.Request)

Login starts a new OAuth 2 user authorization flow.

func (*UserMiddleware) Logout

func (m *UserMiddleware) Logout(w http.ResponseWriter, r *http.Request)

Logout deletes a previously created user session.

func (*UserMiddleware) Prechecker

func (m *UserMiddleware) Prechecker(next http.Handler) http.Handler

Prechecker checks that middleware is in a valid state for OAuth 2 authorization flow execution. In other words, it checks that session values can be obtained from session stores.

func (*UserMiddleware) SessionWrapper

func (m *UserMiddleware) SessionWrapper(next http.Handler) http.Handler

SessionWrapper gets the session value from the user token session store, checks that the session is not new and that it contains a valid OAuth 2 token payload. If any of these conditions are not met, request is passed on to the next handler. Otherwise, the session value and an HTTP client that auto-refreshes the OAuth 2 token are embedded in the HTTP request context, before processing the request further. Finally, it saves the updated token payload in database if the token was refreshed during request handling.

Jump to

Keyboard shortcuts

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