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.

            Source Files