flow

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 14 Imported by: 10

Documentation

Index

Constants

View Source
const AuthorizationExchangeHeader = "X-Authorization-Exchange"

AuthorizationExchangeHeader is the header name used to pass the authorization exchange information by backend for frontend flow

Variables

This section is empty.

Functions

func BuildAuthCodeURL added in v0.21.0

func BuildAuthCodeURL(config *oauth2.Config, options ...Option) (string, error)

BuildAuthCodeURL builds the authorization URL for the OAuth2 flow

func Exchange added in v0.21.0

func Exchange(ctx context.Context, config *oauth2.Config, code string, options ...Option) (*oauth2.Token, error)

Exchange exchanges the authorization code for an access token

func GenerateCodeChallenge added in v0.21.1

func GenerateCodeChallenge(verifier string) string

GenerateCodeChallenge creates a PKCE code challenge from a code verifier

func GenerateCodeVerifier added in v0.21.1

func GenerateCodeVerifier() string

GenerateCodeVerifier creates a random code verifier for PKCE

Types

type AuthFlow

type AuthFlow interface {
	Token(ctx context.Context, config *oauth2.Config, options ...Option) (*oauth2.Token, error)
}

type AuthorizationExchange added in v0.24.0

type AuthorizationExchange struct {
	Code        string
	RedirectURI string
	State       string
}

func (*AuthorizationExchange) FromHeader added in v0.24.0

func (a *AuthorizationExchange) FromHeader(header string)

func (*AuthorizationExchange) ToHeader added in v0.24.0

func (a *AuthorizationExchange) ToHeader() string

type BackendForFrontend added in v0.24.0

type BackendForFrontend struct{}

func (*BackendForFrontend) BeginAuthorization added in v0.24.0

func (b *BackendForFrontend) BeginAuthorization(ctx context.Context, authorizationURI string) (*AuthorizationExchange, error)

type BackendForFrontendFlow added in v0.24.0

type BackendForFrontendFlow interface {
	BeginAuthorization(ctx context.Context, authorizationURI string) (*AuthorizationExchange, error)
}

type BrowserFlow

type BrowserFlow struct {
	NewEndpoint func() (Endpoint, error)
}

func NewBrowserFlow

func NewBrowserFlow(opts ...BrowserFlowOption) *BrowserFlow

NewBrowserFlow create new browser flow

func (*BrowserFlow) Token

func (s *BrowserFlow) Token(ctx context.Context, config *oauth2.Config, options ...Option) (*oauth2.Token, error)

type BrowserFlowOption added in v0.25.0

type BrowserFlowOption func(*BrowserFlow)

BrowserFlowOption represents browser flow

func WithNewEndpoint added in v0.25.0

func WithNewEndpoint(newEndpoint func() (Endpoint, error)) BrowserFlowOption

type Endpoint added in v0.25.0

type Endpoint interface {
	Start()
	Wait() error
	AuthCode() string
	RedirectURL() string
}

type Option

type Option func(*Options)

func WithAuthURLParam

func WithAuthURLParam(key string, value string) Option

func WithCodeVerifier added in v0.21.0

func WithCodeVerifier(codeVerifier string) Option

WithCodeVerifier sets the code verifier for PKCE flow

func WithPKCE

func WithPKCE(enabled bool) Option

WithPKCE enables or disables PKCE flow

func WithPostParam

func WithPostParam(key string, value string) Option

func WithPostParams

func WithPostParams(values map[string]string) Option

func WithRedirectURI added in v0.22.0

func WithRedirectURI(redirectURL string) Option

func WithScopes

func WithScopes(scopes ...string) Option

func WithState

func WithState(state string) Option

type Options

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

func NewOptions

func NewOptions(opts []Option) *Options

func (*Options) Scopes

func (o *Options) Scopes(scopes ...string) []string

func (*Options) State

func (o *Options) State() string

type OutOfBandFlow

type OutOfBandFlow struct{}

func NewOutOfBandFlow

func NewOutOfBandFlow() *OutOfBandFlow

func (*OutOfBandFlow) Token

func (s *OutOfBandFlow) Token(ctx context.Context, config *oauth2.Config, options ...Option) (*oauth2.Token, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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