oauth

package
Version: v0.0.0-...-afa1830 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRedirectErr

func BuildRedirectErr(code merr.Code, desc string, redirectURL *url.URL) string

BuildRedirectErr with an error code and a description

Types

type AuthorizationCodeFlow

type AuthorizationCodeFlow struct {
	// contains filtered or unexported fields
}

AuthorizationCodeFlow (from OpenID Connect) using a private_key_jwt method for the final token exchange more info: https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowSteps allows to perform easily two steps: - the build of the url to ask for an authorization code - the exchange of the code vs final tokens

func NewAuthorizationCodeFlow

func NewAuthorizationCodeFlow(
	cliID string, redConn *redis.Client,
	codeURL string, redirectCodeURL string,
	tokenRester rester.Client, tokenURL string, redirectTokenURL string,
) (*AuthorizationCodeFlow, error)

NewAuthorizationCodeFlow is AuthorizationCodeFlow's constructor

func (*AuthorizationCodeFlow) ExchangeToken

func (acf *AuthorizationCodeFlow) ExchangeToken(c echo.Context)

ExchangeToken using an authorization code then redirect the user agent with information related to operation's success or failure

func (*AuthorizationCodeFlow) RequestCode

func (acf *AuthorizationCodeFlow) RequestCode(w http.ResponseWriter, r *http.Request)

RequestCode by redirecting the user's agent to the authorization server with a well built URL to request a code Required to be keeped for some unofficial/in-house clients.

type AuthorizationCodeInput

type AuthorizationCodeInput struct {
	Scopes []string
	State  string
	Prompt string // Can only be "none" or empty
}

AuthorizationCodeInput contains parameters for obtaining a code it is built from query parameters

type TokenError

type TokenError struct {
	Code  string `json:"error"`
	Desc  string `json:"error_description"`
	Debug string `json:"error_debug"`
}

TokenError represents the body error returned by the authorization server following https://tools.ietf.org/html/rfc6749#section-5.2

type TokenRequest

type TokenRequest struct {
	Code         string
	Scopes       []string
	State        string
	CodeVerifier string
}

TokenRequest contains parameters for exchanging a code against a token it is built from query parameters

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	IDToken     string `json:"id_token"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
}

TokenResponse is the received structure after a successful token exchange

Jump to

Keyboard shortcuts

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