jawsauth

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 12 Imported by: 1

README

build coverage goreport Docs

jawsauth

OAuth2 integration with Jaws sessions using "golang.org/x/oauth2".

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInconsistentState = errors.New("oauth2 inconsistent state")

Functions

This section is empty.

Types

type Config

func (*Config) Build

func (cfg *Config) Build(overrideUrl string) (oauth2cfg *oauth2.Config, err error)

Build creates a oauth2.Config. If overrideUrl is provided, it's scheme, host and port are used instead of the ones in RedirectURL. This is useful when testing.

func (*Config) Validate

func (cfg *Config) Validate() (err error)

type HandleFunc

type HandleFunc func(uri string, handler http.Handler)

type Server

type Server struct {
	*jaws.Jaws
	SessionKey      string // Session value will be of type map[string]any
	SessionEmailKey string // Session value will be a string if available
	LoginURL        string
	LogoutURL       string
	OverrideURL     string
	// contains filtered or unexported fields
}

func New

func New(jw *jaws.Jaws) (srv *Server)

func (*Server) HandleAuthResponse

func (srv *Server) HandleAuthResponse(hw http.ResponseWriter, hr *http.Request)

func (*Server) HandleLogin

func (srv *Server) HandleLogin(hw http.ResponseWriter, hr *http.Request)

func (*Server) HandleLogout

func (srv *Server) HandleLogout(hw http.ResponseWriter, hr *http.Request)

func (*Server) Handler

func (srv *Server) Handler(name string, dot any) http.Handler

Handler returns a http.Handler using a jaws.Template that requires an authenticated user. Sets the jaws Session value srv.SessionKey to what UserInfoURL returned.

func (*Server) SetConfig

func (srv *Server) SetConfig(cfg *Config, handleFn HandleFunc) (err error)

func (*Server) Wrap

func (srv *Server) Wrap(h http.Handler) http.Handler

Wrap returns a http.Handler that requires an authenticated user before invoking h. Sets the jaws Session value srv.SessionKey to what UserInfoURL returned.

Jump to

Keyboard shortcuts

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