refresh

package
v0.0.0-...-36f99de Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 5 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 {
	BaseURL       *url.URL
	CookieManager gopenidclient.CookieManager
	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, refresher Refresher) (cr gopenidclient.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

RootPath is {BaseURL}/refresh

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. The handler MUST be on a subpath of the Handler.BaseURL.

type Refresher

type Refresher interface {
	// Refresh is like [gopenidclient.Provider.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