oauth

package module
v0.0.0-...-28f577a Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 11 Imported by: 0

README

go-oauth2-handlers

OAuth2 helpers for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromErrorContext

func FromErrorContext(ctx context.Context) (error, bool)

func New

func New(loginHandler http.Handler, errorHandler http.Handler, providers ...*ProviderConfig) http.Handler

Types

type ProviderConfig

type ProviderConfig struct {
	Provider ProviderType
	*oauth2.Config
	InfoEndpoint string
	Unmarshal    func(r io.Reader) (*User, error)
}

func FacebookProviderConfig

func FacebookProviderConfig(appId, appSecret, callback string) *ProviderConfig

func GoogleProivderConfig

func GoogleProivderConfig(appId, appSecret, callback string) *ProviderConfig

type ProviderType

type ProviderType string
const (
	ProviderFacebook ProviderType = "facebook"
	ProviderGoogle   ProviderType = "google"
)

type User

type User struct {
	ID        string
	Name      string
	FirstName string
	LastName  string
	Email     string
	Avatar    string
	Provider  ProviderType
}

func FromUserContext

func FromUserContext(ctx context.Context) (*User, bool)

Jump to

Keyboard shortcuts

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