providers

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &http.Client{
	Transport: &http.Transport{
		MaxIdleConnsPerHost: 20,
	},
	Timeout: 10 * time.Second,
}

DefaultClient is the default HTTP client used.

View Source
var ErrNoAuthURL = errors.New("an AuthURL has not been set")

ErrNoAuthURL is returned when an AuthURL has not been set.

View Source
var ErrUnimplemented = errors.New("not implemented")

ErrUnimplemented is returned when a method is not implemented.

Functions

func RegisterProvider

func RegisterProvider(provider ...Provider)

RegisterProvider adds a provider to the list of available providers for use with Goth.

Types

type AuthIntent

type AuthIntent interface {
	// GetAuthURL returns the URL for the authentication end-point.
	GetAuthURL() (string, error)
}

AuthIntent is the type of authentication intent.

type AuthParams

type AuthParams interface {
	Get(string) string
}

AuthParams is the type of authentication parameters.

type Provider

type Provider interface {
	// ID returns the provider's ID.
	ID() string
	// Debug sets the provider's debug mode.
	Debug(bool)
	// Name returns the provider's name.
	Name() string
	// Type returns the provider's type.
	Type() ProviderType
	// BeginAuth starts the authentication process.
	BeginAuth(ctx context.Context, adapter adapters.Adapter, state string) (AuthIntent, error)
	// CompleteAuth completes the authentication process.
	CompleteAuth(ctx context.Context, adapter adapters.Adapter, params AuthParams) (adapters.User, error)
}

Provider needs to be implemented for each 3rd party authentication provider.

func GetProvider

func GetProvider(name string) (Provider, error)

GetProvider returns a previously created provider. If Goth has not been told to use the named provider it will return an error.

type ProviderType

type ProviderType string

PrioviderType is the type of provider.

const (
	// ProviderTypeOAuth2 represents an OAuth2 account type.
	ProviderTypeOAuth2 ProviderType = "oauth2"
	// ProviderTypeOIDC represents an OIDC account type.
	ProviderTypeOIDC ProviderType = "oidc"
	// ProviderTypeSAML represents a SAML account type.
	ProviderTypeSAML ProviderType = "saml"
	// ProviderTypeEmail represents an email account type.
	ProviderTypeEmail ProviderType = "email"
	// ProviderTypeWebAuthn represents a WebAuthn account type.
	ProviderTypeWebAuthn ProviderType = "webauthn"
	// ProviderTypeUnknown represents an unknown account type.
	ProviderTypeUnknown ProviderType = "unknow"
)

type Providers

type Providers map[string]Provider

Providers is list of known/available providers.

func GetProviders

func GetProviders() Providers

GetProviders returns a list of all the providers currently in use.

type UnimplementedProvider

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

UnimplementedProvider is a placeholder for a provider that has not been implemented.

func (*UnimplementedProvider) BeginAuth

BeginAuth starts the authentication process.

func (*UnimplementedProvider) CompleteAuth

CompleteAuth completes the authentication process.

func (*UnimplementedProvider) Debug

func (u *UnimplementedProvider) Debug(debug bool)

Debug sets the provider's debug mode.

func (*UnimplementedProvider) ID

func (u *UnimplementedProvider) ID() string

ID returns the provider's ID.

func (*UnimplementedProvider) Name

func (u *UnimplementedProvider) Name() string

Name returns the provider's name.

func (*UnimplementedProvider) Type

Type returns the provider's type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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