oauth

package
v0.0.0-...-8495beb Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidProvider = errors.New("invalid provider")

Functions

func Build

func Build() fx.Option

Types

type OAuth

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

func New

func New(
	l *zap.Logger,
	gh *github.GitHubProvider,
) *OAuth

func (*OAuth) Provider

func (oa *OAuth) Provider(id string) (Provider, error)

func (*OAuth) Providers

func (oa *OAuth) Providers() []Provider

type Provider

type Provider interface {
	// Enabled tells the OAuth component if the provider is enabled. Providers
	// can be enabled and disabled at initialisation time based on the presence
	// of environment variable configuration for each provider.
	Enabled() bool

	// Provider general information.
	Name() string
	ID() string
	LogoURL() string

	// Link is the actual login link to show to users.
	Link() string

	// Login is the callback function.
	Login(ctx context.Context, state, code string) (*account.Account, error)
}

Provider describes a type that can provide an OAuth2 authentication method for users.

Link simply returns a URL to start the OAuth2 process.

Login is called by the callback and handles the code/token exchange and returns a User object to the caller to be encoded into a cookie.

Directories

Path Synopsis
Package all contains things that are common amongst all providers.
Package all contains things that are common amongst all providers.

Jump to

Keyboard shortcuts

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