refresh

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package refresh uses the refresh-token as a remember token (stored encrypted in a dedicated cookie).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Providers       map[string]Refresher
	BaseURL         *url.URL
	CookiePrefix    string
	CookieEncrypter goath.CookieEncrypter
	MaxAge          int

	LoginChooserHandler http.Handler
}

func (Handler) ClearCookies

func (s Handler) ClearCookies(w http.ResponseWriter, r *http.Request)

func (Handler) HandleRefresh

func (s Handler) HandleRefresh(w http.ResponseWriter, r *http.Request) (providerName string, cr goath.CallbackResult, err error)

HandleRefresh should be mounted on the RootPath URI. It will use the refresh token and return the result. SetRefreshCookie will be automatically called on success.

func (Handler) HandleUnauthenticatedSession

func (s Handler) HandleUnauthenticatedSession(w http.ResponseWriter, r *http.Request)

HandleUnauthenticatedSession should be called when the session expired or is invalid. It will either redirect to the RootPath URI if the provider cookie is found or fallback to the LoginChooserHandler.

func (Handler) RootPath

func (s Handler) RootPath() string

func (Handler) SetRefreshCookie

func (s Handler) SetRefreshCookie(w http.ResponseWriter, provider, refreshToken string)

SetRefreshCookie should be called after initial authentication, to send the refresh-token as an encrypted cookie to the client.

type Refresher

type Refresher interface {
	// Refresh is like Exchange, but using a RefreshToken instead of a code.
	Refresh(refreshToken string) (token *oauth2.Token, unmarshalUser func(interface{}) error, err error)
}

Jump to

Keyboard shortcuts

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