redirect

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package redirect implements redirection based login.

Index

Constants

View Source
const Kind = "browser-redirect"

Variables

This section is empty.

Functions

func IsRedirectRequiredError

func IsRedirectRequiredError(err error) bool

IsRedirectRequiredError determines if an error is a RedirectRequiredError.

func ParseLoginResult

func ParseLoginResult(requestURL string) (state, code string, err error)

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

Interact implements httpbakery.Interactor.

func (*Interactor) Kind

func (*Interactor) Kind() string

Kind 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.

Jump to

Keyboard shortcuts

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