add admin api key for creating accounts

This commit is contained in:
kiwiidb
2022-10-03 14:54:29 +02:00
parent 37bc4075ac
commit 8661225273
5 changed files with 24 additions and 6 deletions

17
lib/tokens/admin.go Normal file
View File

@@ -0,0 +1,17 @@
package tokens
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func AdminTokenMiddleware(token string) echo.MiddlewareFunc {
if token == "" {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return next
}
}
return middleware.KeyAuth(func(auth string, c echo.Context) (bool, error) {
return auth == token, nil
})
}