diff options
author | Wim <wim@42.be> | 2018-02-21 00:48:10 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-02-21 00:48:10 +0100 |
commit | 55ab0c12f12e2f0ee15dccd519e1fca4d011b73b (patch) | |
tree | 8d114d1129424e446a0124b9520d2ff3b2175369 /vendor/github.com/labstack/echo/middleware/key_auth.go | |
parent | d1227b5fc9de9f7a04fbf71292dd224aa8806411 (diff) | |
download | matterbridge-msglm-55ab0c12f12e2f0ee15dccd519e1fca4d011b73b.tar.gz matterbridge-msglm-55ab0c12f12e2f0ee15dccd519e1fca4d011b73b.tar.bz2 matterbridge-msglm-55ab0c12f12e2f0ee15dccd519e1fca4d011b73b.zip |
Update vendor labstack/echo
Diffstat (limited to 'vendor/github.com/labstack/echo/middleware/key_auth.go')
-rw-r--r-- | vendor/github.com/labstack/echo/middleware/key_auth.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/vendor/github.com/labstack/echo/middleware/key_auth.go b/vendor/github.com/labstack/echo/middleware/key_auth.go index 24625260..4990afd9 100644 --- a/vendor/github.com/labstack/echo/middleware/key_auth.go +++ b/vendor/github.com/labstack/echo/middleware/key_auth.go @@ -20,7 +20,8 @@ type ( // Possible values: // - "header:<name>" // - "query:<name>" - KeyLookup string `json:"key_lookup"` + // - "form:<name>" + KeyLookup string `yaml:"key_lookup"` // AuthScheme to be used in the Authorization header. // Optional. Default value "Bearer". @@ -81,6 +82,8 @@ func KeyAuthWithConfig(config KeyAuthConfig) echo.MiddlewareFunc { switch parts[0] { case "query": extractor = keyFromQuery(parts[1]) + case "form": + extractor = keyFromForm(parts[1]) } return func(next echo.HandlerFunc) echo.HandlerFunc { @@ -134,3 +137,14 @@ func keyFromQuery(param string) keyExtractor { return key, nil } } + +// keyFromForm returns a `keyExtractor` that extracts key from the form. +func keyFromForm(param string) keyExtractor { + return func(c echo.Context) (string, error) { + key := c.FormValue(param) + if key == "" { + return "", errors.New("Missing key in the form") + } + return key, nil + } +} |