oauth

package
v0.0.0-...-dec25df Latest Latest
Warning

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

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

Documentation

Overview

Package oauth provides the integration with Google OAuth.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHttpRequestUserId

func GetHttpRequestUserId(r *http.Request) int64

Return userId stored in Context associated with this session.

func SetHttpRequestUserId

func SetHttpRequestUserId(r *http.Request, id int64) *http.Request

Store the userId in Conext of this session.

Types

type GoogleConfig

type GoogleConfig struct {
	ClientID, ClientSecret, CookieSecret string
	LoginURL, RedirectURL                string
	SessionName, SessionUserKey          string
	Debug                                bool // if true, allows non-SSL cookies
	TokenChecker                         *func(r *http.Request) int64
	UserValidator                        userValidator
}

type Provider

type Provider interface {
	Login(successURL string) http.Handler
	Callback() http.Handler
	Logout() http.Handler
	RequireLogin(h http.Handler, allowToken bool) http.Handler
	UpdateCreds(clientId, secret, redirect string)
	HasCreds() bool
}

Provider interface implements the functions necessary for OAuth authentication.

func NewGoogle

func NewGoogle(cfg GoogleConfig) Provider

Return a new instance of a Google OAuth Provider. This implementation maintains a session stored in an encrypted cookie using gorilla/securecookie.

Jump to

Keyboard shortcuts

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