dashboard: Can restrict access through htpasswd

This commit is contained in:
nemunaire 2022-06-06 10:48:06 +02:00
commit 437ed4d393
5 changed files with 89 additions and 2 deletions

View file

@ -15,7 +15,7 @@ type App struct {
bind string
}
func NewApp(baseURL string, bind string) App {
func NewApp(htpasswd_file *string, baseURL string, bind string) App {
gin.ForceConsoleColor()
router := gin.Default()
@ -29,6 +29,11 @@ func NewApp(baseURL string, bind string) App {
} else {
baserouter = router.Group("")
}
if htpasswd_file != nil && len(*htpasswd_file) > 0 {
baserouter.Use(Htpassword(*htpasswd_file))
}
declareStaticRoutes(baserouter, baseURL)
app := App{