internal

package
v0.0.0-...-905aa70 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginUrl    = "/_p/login"
	LogoutUrl   = "/_p/logout"
	CallbackUrl = "/_p/callback"

	AuthNamespace = "/_p/" // allow requests starting with this prefix

	UserID          = "uid"
	UserAccessToken = "uatk"
)
View Source
const (
	INDEX_HTML = "index.html"
)
View Source
const (
	// ShutdownDelay is the time to wait for all request, go-routines etc complete
	ShutdownDelay = 10 // seconds
)

Variables

View Source
var (
	// ErrInvalidConfiguration indicates that parameters used to configure the service were invalid
	ErrInvalidConfiguration = errors.New("invalid configuration")
)

Functions

func Authenticate

func Authenticate(c echo.Context, user goth.User) error

func Callback

func Callback(c echo.Context) error

func GetFromSession

func GetFromSession(c echo.Context, key string) (string, error)

GetFromSession retrieves a previously-stored value from the session. If no value has previously been stored at the specified key, it will return an error.

func GetProviderName

func GetProviderName(c echo.Context) (string, error)

GetProviderName is a function used to get the name of a provider for a given request. By default, this provider is fetched from the URL query string.

func GetState

func GetState(c echo.Context) string

GetState gets the state returned by the provider during the callback. This is used to prevent CSRF attacks, see http://tools.ietf.org/html/rfc6749#section-10.12

func IsAuthenticated

func IsAuthenticated(c echo.Context) bool

func Login

func Login(c echo.Context) error

func Logout

func Logout(c echo.Context) error

func SetState

func SetState(c echo.Context) string

SetState sets the state string associated with the given request. If no state string is associated with the request, one will be generated. This state is sent to the provider and can be retrieved during the callback.

func Static

func Static(root string) echo.MiddlewareFunc

Static returns a Static middleware to serves static content from the provided root directory.

func StoreInSession

func StoreInSession(c echo.Context, key string, value string) error

StoreInSession stores a specified key/value pair in the session.

Types

type RouterFunc

type RouterFunc func() *echo.Echo

RouterFunc creates a mux

type Server

type Server interface {
	StartBlocking()
	Stop()
}

Server is an interface for the HTTP server

func NewHttp

func NewHttp(router RouterFunc, shutdown ShutdownFunc, errorHandler echo.HTTPErrorHandler) (Server, error)

New returns a new HTTP server

type ShutdownFunc

type ShutdownFunc func(*echo.Echo)

ShutdownFunc is called before the server stops

type StaticConfig

type StaticConfig struct {
	// Root directory from where the static content is served.
	// Required.
	Root string `yaml:"root"`

	// Index file for serving a directory.
	// Optional. Default value "index.html".
	Index string `yaml:"index"`

	// Enable HTML5 mode by forwarding all not-found requests to root so that
	// SPA (single-page application) can handle the routing.
	// Optional. Default value false.
	HTML5 bool `yaml:"html5"`

	// Filesystem provides access to the static content.
	// Optional. Defaults to http.Dir(config.Root)
	Filesystem http.FileSystem `yaml:"-"`
}

StaticConfig defines the config for Static middleware.

Jump to

Keyboard shortcuts

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