1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
package auth
import (
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
)
func Middleware() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) (err error) {
username := c.Request().URL.Query().Get("username")
if username == "reject" {
return echo.ErrUnauthorized.SetInternal(errors.Errorf("user %s is not authorized", username))
}
return next(c)
}
}
}
|