@@ -30,6 +30,9 @@ func New(logger *slog.Logger, database db.Database, buildTime string, sha1ver st
|
||||
|
||||
mux := http.NewServeMux()
|
||||
requireAuth := middleware.RequireAuth(logger, settings)
|
||||
withAuth := func(next http.HandlerFunc) http.Handler {
|
||||
return requireAuth(http.HandlerFunc(next))
|
||||
}
|
||||
withAuthRole := func(next http.HandlerFunc, roles ...string) http.Handler {
|
||||
wrapped := http.Handler(http.HandlerFunc(next))
|
||||
if len(roles) > 0 {
|
||||
@@ -78,6 +81,7 @@ func New(logger *slog.Logger, database db.Database, buildTime string, sha1ver st
|
||||
mux.Handle("/api/snapshots/regenerate-hourly-reports", withAuthRole(h.SnapshotRegenerateHourlyReports, middleware.RoleAdmin))
|
||||
mux.Handle("/api/diagnostics/daily-creation", withAuthRole(h.DailyCreationDiagnostics, middleware.RoleViewer))
|
||||
mux.HandleFunc("/api/auth/login", h.AuthLogin)
|
||||
mux.Handle("/api/auth/me", withAuth(h.AuthMe))
|
||||
mux.HandleFunc("/vm/trace", h.VmTrace)
|
||||
mux.HandleFunc("/vcenters", h.VcenterList)
|
||||
mux.HandleFunc("/vcenters/totals", h.VcenterTotals)
|
||||
|
||||
Reference in New Issue
Block a user