1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-05 00:58:47 +02:00

Fixed basic-auth middleware

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-09-05 10:20:10 -07:00
parent 025c53d4cf
commit 4850d69c30
2 changed files with 5 additions and 1 deletions

View File

@ -13,6 +13,7 @@ type (
Skipper Skipper
// Validator is a function to validate BasicAuth credentials.
// Required.
Validator BasicAuthValidator
}
@ -46,6 +47,9 @@ func BasicAuth(fn BasicAuthValidator) echo.MiddlewareFunc {
// See `BasicAuth()`.
func BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc {
// Defaults
if config.Validator == nil {
panic("basic-auth middleware requires validator function")
}
if config.Skipper == nil {
config.Skipper = DefaultBasicAuthConfig.Skipper
}