oauth

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseHandler added in v0.3.0

type BaseHandler struct {
	oauth2.Config
	HTTPClient *http.Client
	Logger     *slog.Logger
}

BaseHandler implements the generic part of a Handler.

type GitHubHandler added in v0.3.0

type GitHubHandler struct {
	BaseHandler
}

GitHubHandler performs the OAuth handshake using GitHub as authenticator and get the email address for the authenticated user.

func NewGitHubHandler added in v0.3.0

func NewGitHubHandler(clientID, clientSecret, authURL string, logger *slog.Logger) *GitHubHandler

NewGitHubHandler returns a new Handler for GitHub.

func (GitHubHandler) GetUserEmailAddress added in v0.3.0

func (h GitHubHandler) GetUserEmailAddress(code string) (string, error)

GetUserEmailAddress returns the authenticated user's email address

type GoogleHandler added in v0.3.0

type GoogleHandler struct {
	BaseHandler
}

GoogleHandler performs the OAuth handshake using Google as authenticator and get the email address for the authenticated user.

func NewGoogleHandler added in v0.3.0

func NewGoogleHandler(clientID, clientSecret, authURL string, logger *slog.Logger) *GoogleHandler

NewGoogleHandler returns a new Handler for Google.

func (GoogleHandler) GetUserEmailAddress added in v0.3.0

func (h GoogleHandler) GetUserEmailAddress(code string) (string, error)

GetUserEmailAddress returns the authenticated user's email address

type Handler

type Handler interface {
	AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string
	GetUserEmailAddress(code string) (string, error)
}

A Handler performs the OAuth handshake and get the email address for the authenticated user.

func NewHandler added in v0.3.0

func NewHandler(provider, clientID, clientSecret, authURL string, logger *slog.Logger) (Handler, error)

NewHandler returns a new Handler for the selected provider. Currently, google and github are supported.

Jump to

Keyboard shortcuts

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