1
0
mirror of https://github.com/labstack/echo.git synced 2025-11-29 22:48:07 +02:00

Signature changed for key and basic auth validator

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2017-04-18 15:40:28 -07:00
parent c3069d42c1
commit 5f392f3bb1
6 changed files with 20 additions and 14 deletions

View File

@@ -32,7 +32,7 @@ type (
}
// KeyAuthValidator defines a function to validate KeyAuth credentials.
KeyAuthValidator func(string, echo.Context) bool
KeyAuthValidator func(string, echo.Context) (error, bool)
keyExtractor func(echo.Context) (string, error)
)
@@ -94,7 +94,10 @@ func KeyAuthWithConfig(config KeyAuthConfig) echo.MiddlewareFunc {
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
if config.Validator(key, c) {
err, valid := config.Validator(key, c)
if err != nil {
return err
} else if valid {
return next(c)
}