oauth2

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyUsername = errors.New("oidc: username is empty")
)

Functions

func NewGoogleProvider added in v2.0.48

func NewGoogleProvider(clientID, clientSecret, redirectURL string) *googleProvider

func NewOidcProvider added in v2.0.48

func NewOidcProvider(ctx context.Context, clientID, clientSecret, redirectURL, discoveryEndpoint string) (*oidcProvider, error)

Types

type Authorization added in v2.0.48

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

func GenerateAuthorization added in v2.0.48

func GenerateAuthorization(config *oauth2.Config) *Authorization

func (*Authorization) CodeVerifier added in v2.0.48

func (u *Authorization) CodeVerifier() string

func (*Authorization) RedirectURL added in v2.0.48

func (u *Authorization) RedirectURL() string

func (*Authorization) State added in v2.0.48

func (u *Authorization) State() string

type Manager

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

func NewManager

func NewManager(ctx context.Context, clientID, clientSecret, redirectURL, oidcDiscoveryEndpoint string) *Manager

func (*Manager) AddProvider

func (m *Manager) AddProvider(name string, provider Provider)

func (*Manager) FindProvider

func (m *Manager) FindProvider(name string) (Provider, error)

type Profile

type Profile struct {
	Key      string
	ID       string
	Username string
}

Profile is the OAuth2 user profile.

func (Profile) String

func (p Profile) String() string

type Provider

type Provider interface {
	GetConfig() *oauth2.Config
	GetUserExtraKey() string
	GetProfile(ctx context.Context, code, codeVerifier string) (*Profile, error)
	PopulateUserCreationWithProfileID(user *model.UserCreationRequest, profile *Profile)
	PopulateUserWithProfileID(user *model.User, profile *Profile)
	UnsetUserProfileID(user *model.User)
}

Provider is an interface for OAuth2 providers.

Jump to

Keyboard shortcuts

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