Documentation
¶
Index ¶
- Constants
- func AcceptJSON(next echo.HandlerFunc) echo.HandlerFunc
- func BasicAuth(secretFileName string) echo.MiddlewareFunc
- func CORS(next echo.HandlerFunc) echo.HandlerFunc
- func Compose(handler echo.HandlerFunc, mws ...echo.MiddlewareFunc) echo.HandlerFunc
- func ContentTypeJSON(next echo.HandlerFunc) echo.HandlerFunc
- func GetInstance(c echo.Context) *instance.Instance
- func IsLoggedIn(c echo.Context) bool
- func LoadSession(next echo.HandlerFunc) echo.HandlerFunc
- func NeedInstance(next echo.HandlerFunc) echo.HandlerFunc
- func Secure(conf *SecureConfig) echo.MiddlewareFunc
- func SplitHost(host string) (instanceHost, appSlug string)
- type CSPSource
- type SecureConfig
- type XFrameOption
Constants ¶
const ( // XFrameDeny is the DENY option of the X-Frame-Options header. XFrameDeny XFrameOption = "DENY" // XFrameSameOrigin is the SAMEORIGIN option of the X-Frame-Options header. XFrameSameOrigin = "SAMEORIGIN" // XFrameAllowFrom is the ALLOW-FROM option of the X-Frame-Options header. It // should be used along with the XFrameAllowed field of SecureConfig. XFrameAllowFrom = "ALLOW-FROM" // CSPSrcSelf is the 'self' option of a CSP source. CSPSrcSelf CSPSource = iota // CSPSrcParent adds the parent domain as an eligible CSP source. CSPSrcParent // CSPSrcParentSubdomains add all the parent's subdomains as eligibles CSP // sources. CSPSrcParentSubdomains // CSPSrcAny is the '*' option. It allows any domain as an eligible source. CSPSrcAny )
Variables ¶
This section is empty.
Functions ¶
func AcceptJSON ¶
func AcceptJSON(next echo.HandlerFunc) echo.HandlerFunc
AcceptJSON is an echo middleware that checks that the HTTP Accept header is compatible with application/json
func BasicAuth ¶
func BasicAuth(secretFileName string) echo.MiddlewareFunc
BasicAuth use HTTP basic authentication to authenticate a user. The secret of the user should be stored in a file with the specified name, stored in one of the the config.Paths directories.
The format of the secret is the same as our hashed passwords in database: a scrypt hash with a salt contained in the value.
func CORS ¶
func CORS(next echo.HandlerFunc) echo.HandlerFunc
CORS returns a Cross-Origin Resource Sharing (CORS) middleware. See: https://developer.mozilla.org/en/docs/Web/HTTP/Access_control_CORS
func Compose ¶
func Compose(handler echo.HandlerFunc, mws ...echo.MiddlewareFunc) echo.HandlerFunc
Compose can be used to compose a list of middlewares together with a main handler function. It returns a new handler that should be the composition of all the middlwares with the initial handler.
func ContentTypeJSON ¶
func ContentTypeJSON(next echo.HandlerFunc) echo.HandlerFunc
ContentTypeJSON is an echo middleware that checks that the HTTP Content-Type header is compatible with application/json
func GetInstance ¶
GetInstance will return the instance linked to the given echo context or panic if none exists
func IsLoggedIn ¶
IsLoggedIn returns true if the context has a valid session cookie.
func LoadSession ¶
func LoadSession(next echo.HandlerFunc) echo.HandlerFunc
LoadSession is a middlewares that sets logged-in to true if the context has a valid session cookie.
func NeedInstance ¶
func NeedInstance(next echo.HandlerFunc) echo.HandlerFunc
NeedInstance is an echo middleware which will display an error if there is no instance.
func Secure ¶
func Secure(conf *SecureConfig) echo.MiddlewareFunc
Secure returns a Middlefunc that can be used to define all the necessary secure headers. It is configurable with a SecureConfig object.
Types ¶
type CSPSource ¶
type CSPSource int
CSPSource type are the different types of CSP headers sources definitions. Each source type defines a different acess policy.
type SecureConfig ¶
type SecureConfig struct {
HSTSMaxAge time.Duration
CSPDefaultSrc []CSPSource
CSPScriptSrc []CSPSource
CSPFrameSrc []CSPSource
CSPConnectSrc []CSPSource
CSPFontSrc []CSPSource
CSPImgSrc []CSPSource
CSPManifestSrc []CSPSource
CSPMediaSrc []CSPSource
CSPObjectSrc []CSPSource
CSPStyleSrc []CSPSource
CSPWorkerSrc []CSPSource
XFrameOptions XFrameOption
XFrameAllowed string
}
SecureConfig defines the config for Secure middleware.
type XFrameOption ¶
type XFrameOption string
XFrameOption type for the values of the X-Frame-Options header.