gogae

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

README

gogae

Collection of tools for golang Google App Engine standard V2 servers

Handles OAuthv2 flow, Google API client, JWT authentication and CloudSQL access.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	Project string
	Prefix  string
	OAuth   struct {
		ClientID     string
		ClientSecret string
		RedirectURL  string
		Scopes       []string
	}
	JWT struct {
		Secret string
	}
}

type AuthMiddleware

type AuthMiddleware struct {
	Config AuthConfig
	// contains filtered or unexported fields
}

func NewAuthMiddleware

func NewAuthMiddleware(handler http.Handler, config AuthConfig, userLoadFunction func(context context.Context, config *oauth2.Config, token *oauth2.Token) (string, error), prefix string) *AuthMiddleware

func (*AuthMiddleware) ServeHTTP

func (s *AuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type CloudSQLConfig

type CloudSQLConfig struct {
	User     string
	Password string
	Instance string
	DbName   string
}

type DecryptedToken

type DecryptedToken struct {
	Claims  jwt.Claims
	Session UserSession
}

type Gogae

type Gogae struct {
	Router *httprouter.Router
	Auth   *AuthMiddleware
	Db     *sql.DB
	Log    *logrus.Logger
}

func InitGogae

func InitGogae(config GogaeConfig, userLoadFunction func(context context.Context, config *oauth2.Config, token *oauth2.Token) (string, error)) (Gogae, error)

func (Gogae) Handle

func (g Gogae) Handle(f Handler) func(w http.ResponseWriter, r *http.Request, params httprouter.Params)

func (*Gogae) Start

func (g *Gogae) Start()

type GogaeConfig

type GogaeConfig struct {
	AuthConfig     AuthConfig
	CloudSQLConfig *CloudSQLConfig
}

type Handler

type Handler func(context RequestContext) (interface{}, int, error)

type RequestContext

type RequestContext struct {
	Request      *http.Request
	Params       httprouter.Params
	JWTToken     *DecryptedToken
	UserDataJson string
	Client       *http.Client
	Log          *logrus.Entry
	// contains filtered or unexported fields
}

func (RequestContext) Redirect

func (r RequestContext) Redirect(target string, code int) (interface{}, int, error)

type UserInfo

type UserInfo struct {
	Picture       string `json:"picture"`
	Email         string `json:"email"`
	Link          string `json:"link"`
	Id            string `json:"id"`
	Hd            string `json:"hd"`
	VerifiedEmail bool   `json:"verified_email"`
}

type UserSession

type UserSession struct {
	Token          *oauth2.Token
	UserData       string
	AuthMiddleware *AuthMiddleware
}

Jump to

Keyboard shortcuts

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