auth

package
v0.0.0-...-57dad53 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (

	// ProviderKey provides access to the Provider interface upon successful auth.
	ProviderKey = "provider"

	// ErrorKey provides access to the error message when auth fails.
	ErrorKey = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ClientID       string
	ClientSecret   string
	RedirectURL    string
	SuccessHandler http.Handler
	ErrorHandler   http.Handler
}

Config stores configuration information for a specific provider.

type Facebook

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

Facebook provides a Provider implementation for Facebook auth.

func NewFacebook

func NewFacebook(cfg *Config) *Facebook

func (*Facebook) CallbackHandler

func (f *Facebook) CallbackHandler() http.Handler

func (*Facebook) LoginHandler

func (f *Facebook) LoginHandler() http.Handler

func (*Facebook) Name

func (f *Facebook) Name() string

func (*Facebook) User

func (f *Facebook) User(ctx context.Context) (*User, error)

type Google

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

Google provides a Provider implementation for Google auth.

func NewGoogle

func NewGoogle(cfg *Config) *Google

func (*Google) CallbackHandler

func (g *Google) CallbackHandler() http.Handler

func (*Google) LoginHandler

func (g *Google) LoginHandler() http.Handler

func (*Google) Name

func (g *Google) Name() string

func (*Google) User

func (g *Google) User(ctx context.Context) (*User, error)

type Provider

type Provider interface {

	// Name returns a unique name for the provider.
	Name() string

	// LoginHandler returns an HTTP handler for beginning auth.
	LoginHandler() http.Handler

	// CallbackHandler returns an HTTP handler for completing auth.
	CallbackHandler() http.Handler

	// User returns information about the user.
	User(context.Context) (*User, error)
}

Provider implements authentication for a specific provider.

type User

type User struct {
	ID      string
	Name    string
	Email   string
	Picture io.ReadCloser
}

User stores user information provided by a provider.

Jump to

Keyboard shortcuts

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