Credential of administration api
All checks were successful
release-nightly / build-docker (push) Successful in 1m3s

This commit is contained in:
2023-11-25 00:34:51 +08:00
parent c4c6638144
commit b1a6364618
6 changed files with 107 additions and 24 deletions

View File

@@ -4,6 +4,7 @@ import (
roadsign "code.smartsheep.studio/goatworks/roadsign/pkg"
"fmt"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/basicauth"
"github.com/spf13/viper"
)
@@ -17,6 +18,13 @@ func InitAdministration() *fiber.App {
TrustedProxies: viper.GetStringSlice("security.administration_trusted_proxies"),
})
app.Use(basicauth.New(basicauth.Config{
Realm: fmt.Sprintf("RoadSign v%s", roadsign.AppVersion),
Authorizer: func(_, password string) bool {
return password == viper.GetString("security.credential")
},
}))
webhooks := app.Group("/webhooks").Name("WebHooks")
{
webhooks.Put("/publish/:site/:upstream", doPublish)