Documentation ¶
Index ¶
- Constants
- Variables
- func Authenticate(c echo.Context, user goth.User) error
- func Callback(c echo.Context) error
- func GetFromSession(c echo.Context, key string) (string, error)
- func GetProviderName(c echo.Context) (string, error)
- func GetState(c echo.Context) string
- func IsAuthenticated(c echo.Context) bool
- func Login(c echo.Context) error
- func Logout(c echo.Context) error
- func SetState(c echo.Context) string
- func Static(root string) echo.MiddlewareFunc
- func StoreInSession(c echo.Context, key string, value string) error
- type RouterFunc
- type Server
- type ShutdownFunc
- type StaticConfig
Constants ¶
const ( LoginUrl = "/_p/login" LogoutUrl = "/_p/logout" CallbackUrl = "/_p/callback" AuthNamespace = "/_p/" // allow requests starting with this prefix UserID = "uid" UserAccessToken = "uatk" )
const (
INDEX_HTML = "index.html"
)
const ( // ShutdownDelay is the time to wait for all request, go-routines etc complete ShutdownDelay = 10 // seconds )
Variables ¶
var ( // ErrInvalidConfiguration indicates that parameters used to configure the service were invalid ErrInvalidConfiguration = errors.New("invalid configuration") )
Functions ¶
func Authenticate ¶
func GetFromSession ¶
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 ¶
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 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 ¶
StoreInSession stores a specified key/value pair in the session.
Types ¶
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.