auth

package
v0.0.0-...-91518e1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoogleProvider = "Google"
)

Available providers.

Variables

This section is empty.

Functions

This section is empty.

Types

type Google

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

Google is the provider for Google Authentication.

func NewGoogleProvider

func NewGoogleProvider(clientID, clientSecret, baseURL string) Google

NewGoogleProvider initializes the provider for Gooogle.

func (Google) AccessToken

func (g Google) AccessToken(code string) (*oauth2.Token, error)

AccessToken retrieves an access token user has returned from Google.

func (Google) Name

func (Google) Name() string

Name returns the provider's name.

func (Google) RedirectURL

func (g Google) RedirectURL() string

RedirectURL returns the redirect URL for authentication.

func (Google) UserInfo

func (g Google) UserInfo(token *oauth2.Token) (u ProviderUser, err error)

UserInfo retrieves information about the user from the provider.

type Provider

type Provider interface {
	// Returns the provider's name.
	Name() string

	// Returns the redirect URL for authentication with the provider.
	RedirectURL() string

	// Retrieves an access token user has returned from provider.
	AccessToken(code string) (*oauth2.Token, error)

	// Retrieves information about the user from the provider.
	UserInfo(token *oauth2.Token) (ProviderUser, error)
}

Provider is an authentication provider such as Facebook and Google.

type ProviderUser

type ProviderUser struct {
	UserID      string
	Email       string
	Name        string
	Lastname    string
	Fullname    string
	AccessToken string
}

ProviderUser is information about an user retrieved from provider.

Jump to

Keyboard shortcuts

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