Documentation ¶
Overview ¶
Package redirect implements redirection based login.
Index ¶
- Constants
- func IsRedirectRequiredError(err error) bool
- func ParseLoginResult(requestURL string) (state, code string, err error)
- func SetInteraction(ierr *httpbakery.Error, loginURL, dischargeTokenURL string)
- type DischargeTokenRequest
- type DischargeTokenResponse
- type InteractionInfo
- type Interactor
- type RedirectRequiredError
Constants ¶
const Kind = "browser-redirect"
Variables ¶
This section is empty.
Functions ¶
func IsRedirectRequiredError ¶
IsRedirectRequiredError determines if an error is a RedirectRequiredError.
func ParseLoginResult ¶
ParseLoginResult extracts the result from a response callback.
func SetInteraction ¶
func SetInteraction(ierr *httpbakery.Error, loginURL, dischargeTokenURL string)
SetInteraction adds interaction info the the browser-redirect interaction type.
Types ¶
type DischargeTokenRequest ¶
type DischargeTokenRequest struct { httprequest.Route `httprequest:"POST"` Body struct { Code string `json:"code"` } `httprequest:",body"` }
DischargeTokenRequest represents a request to the DischargeTokenURL.
type DischargeTokenResponse ¶
type DischargeTokenResponse struct {
DischargeToken *httpbakery.DischargeToken `json:"token,omitempty"`
}
DischargeTokenResponse contains a response from a DischargeTokenURL.
type InteractionInfo ¶
type InteractionInfo struct { // LoginURL contains the URL to redirect to in order to start a // login attempt. LoginURL string // DischargeTokenURL contains the URL that is used to swap a // login code for a discharge token. DischargeTokenURL string }
func (InteractionInfo) GetDischargeToken ¶
func (i InteractionInfo) GetDischargeToken(ctx context.Context, code string) (*httpbakery.DischargeToken, error)
GetDischargeToken retrieves the discharge token associated with the given code.
func (InteractionInfo) RedirectURL ¶
func (i InteractionInfo) RedirectURL(returnTo, state string) string
RedirectURL calculates the URL to redirect to in order to initate a browser-redirect login.
type Interactor ¶
type Interactor struct {
// contains filtered or unexported fields
}
func (*Interactor) Interact ¶
func (i *Interactor) Interact(ctx context.Context, _ *httpbakery.Client, _ string, ierr *httpbakery.Error) (*httpbakery.DischargeToken, error)
Interact implements httpbakery.Interactor.
func (*Interactor) SetDischargeToken ¶
func (i *Interactor) SetDischargeToken(loginURL string, dt *httpbakery.DischargeToken)
SetDischargeToken sets a discharge token for a particular login URL.
type RedirectRequiredError ¶
type RedirectRequiredError struct {
InteractionInfo InteractionInfo
}
A RedirectRequiredError is the type of error returned from an interactor when an interaction via redirection is required.
func (RedirectRequiredError) Error ¶
func (e RedirectRequiredError) Error() string
Error implements error.