auth

package
v1.0.1-0...-3f27a16 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoogleAuth

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

GoogleAuth is the Google authentication setup

func New

func New(authConfig *GoogleAuthConfig) *GoogleAuth

New creates a new GoogleAuth instance

func (*GoogleAuth) GetAndDelete

func (a *GoogleAuth) GetAndDelete(state string) bool

GetAndDelete looks up an auth state and deletes it if found. If the auth state is found it returns true, otherwise it returns false.

func (*GoogleAuth) GoogleCallbackHandler

func (a *GoogleAuth) GoogleCallbackHandler(w http.ResponseWriter, r *http.Request)

GoogleCallbackHandler handles the callback from Google

func (*GoogleAuth) GoogleLoginHandler

func (a *GoogleAuth) GoogleLoginHandler(w http.ResponseWriter, r *http.Request)

GoogleLoginHandler handles the redirect to Google

func (*GoogleAuth) NewAuthState

func (a *GoogleAuth) NewAuthState(r *http.Request) string

NewAuthState generates a new state string and stores it for future comparison

type GoogleAuthConfig

type GoogleAuthConfig struct {
	ClientID      string
	ClientSecret  string
	CallbackURL   string
	ErrorURL      string
	Scopes        []string
	LoginCallback LoginFunc
}

GoogleAuthConfig represents the configuration for GoogleAuth

type LoginFunc

type LoginFunc func(w http.ResponseWriter, r *http.Request, u *Userinfo)

LoginFunc is called when a user has successfully logged in

type Userinfo

type Userinfo struct {
	ID            string `json:"id"`
	Email         string `json:"email"`
	VerifiedEmail bool   `json:"verified_email"`
	Name          string `json:"name"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Picture       string `json:"picture"`
	Locale        string `json:"locale"`
	HostDomain    string `json:"hd"`
}

Userinfo contains the information we get from Google

Jump to

Keyboard shortcuts

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