oauth2

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ProviderName string         // Name of the OAuth2 provider
	OAuth2       *oauth2.Config // OAuth2 configuration
	Extractor    DataExtractor  // Function to extract user data from token
	StateCode    string         // State code for CSRF protection
}

Config holds the OAuth2 authentication configuration.

func (*Config) LoginURL

func (c *Config) LoginURL(params []elogin.URLParam) string

LoginURL generates the OAuth2 login URL with the provided parameters.

func (*Config) OAuth2Config

func (c *Config) OAuth2Config() *oauth2.Config

OAuth2Config returns the underlying OAuth2 configuration.

func (*Config) Protocol

func (c *Config) Protocol() string

Protocol returns the authentication protocol name.

func (*Config) Provider

func (c *Config) Provider() string

Provider returns the OAuth2 provider name.

func (*Config) UserData

func (c *Config) UserData(ctx context.Context, values url.Values, params []elogin.URLParam) (*elogin.Token, *elogin.UserData, error)

UserData exchanges the authorization code for a token and extracts user data.

type DataExtractor

type DataExtractor func(ctx context.Context, token *oauth2.Token, oauth2conf *oauth2.Config) (*elogin.UserData, error)

DataExtractor extracts user data from an OAuth2 token.

Jump to

Keyboard shortcuts

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