forsooth

package module
v0.0.0-...-6600ce4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

README

forsooth

Oauth2 handler for my websites, chained to google. I know, it's been done, but I'm learning

Documentation

Overview

Package forsooth provides a dropin Oauth2 handler for gogle logins

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomString

func RandomString(n int) string

RandomString produces a base64 string (websafe?) from n random bytes

Types

type ActiveSession

type ActiveSession struct {
	SessionID string            `json:"sessionid"`
	User      GoogleUserProfile `json:"auth_user"`
	Token     string            `json:"token"`
	State     string            `json:"state"`
	Expires   time.Time         `json:"exipires"`
}

ActiveSession to serialize and track valid tokens

func GetSession

func GetSession(w http.ResponseWriter, r *http.Request) *ActiveSession

GetSession returns the logged in user or cleans up if youve expired

type Forsooth

type Forsooth struct {
	ClientID     string         `yaml:"client_id"`
	ClientSecret string         `yaml:"client_secret"`
	RedirectURL  string         `yaml:"redirect_url"`
	Scopes       []string       `yaml:"scopes"`
	Conf         *oauth2.Config `yaml:-`
}

Forsooth is the config object for the funcs

func (*Forsooth) LoadConfig

func (f *Forsooth) LoadConfig(r *io.Reader)

type GoogleUserProfile

type GoogleUserProfile struct {
	Email    string `json:"email"`
	Verified bool   `json:"verified_email"`
	ID       string `json:"id"`
	Picture  string `json:"picture"`
}

GoogleUserProfile catches user data

type OauthLogin

type OauthLogin struct {
	NextHandler http.Handler
}

OauthLogin type for oauth handler

func NewLoginHandler

func NewLoginHandler(next http.Handler) OauthLogin

NewLoginHandler generates a login middleware

func NewLogoutHandler

func NewLogoutHandler(next http.Handler) OauthLogin

NewLogoutHandler generates a login middleware

func (OauthLogin) ServeHTTP

func (l OauthLogin) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP makes OauthLogin a http.Handler

Jump to

Keyboard shortcuts

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