2018-06-11 13:13:19 +00:00
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
2018-09-10 10:01:38 +00:00
|
|
|
httperror "github.com/portainer/libhttp/error"
|
2018-06-11 13:13:19 +00:00
|
|
|
"github.com/portainer/portainer"
|
|
|
|
"github.com/portainer/portainer/http/security"
|
|
|
|
)
|
|
|
|
|
2018-11-23 19:40:56 +00:00
|
|
|
func hideFields(settings *portainer.Settings) {
|
|
|
|
settings.LDAPSettings.Password = ""
|
|
|
|
}
|
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
// Handler is the HTTP handler used to handle settings operations.
|
|
|
|
type Handler struct {
|
|
|
|
*mux.Router
|
|
|
|
SettingsService portainer.SettingsService
|
|
|
|
LDAPService portainer.LDAPService
|
|
|
|
FileService portainer.FileService
|
2018-07-11 08:39:20 +00:00
|
|
|
JobScheduler portainer.JobScheduler
|
2018-11-06 09:49:48 +00:00
|
|
|
ScheduleService portainer.ScheduleService
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewHandler creates a handler to manage settings operations.
|
|
|
|
func NewHandler(bouncer *security.RequestBouncer) *Handler {
|
|
|
|
h := &Handler{
|
|
|
|
Router: mux.NewRouter(),
|
|
|
|
}
|
|
|
|
h.Handle("/settings",
|
|
|
|
bouncer.AdministratorAccess(httperror.LoggerHandler(h.settingsInspect))).Methods(http.MethodGet)
|
|
|
|
h.Handle("/settings",
|
|
|
|
bouncer.AdministratorAccess(httperror.LoggerHandler(h.settingsUpdate))).Methods(http.MethodPut)
|
|
|
|
h.Handle("/settings/public",
|
|
|
|
bouncer.PublicAccess(httperror.LoggerHandler(h.settingsPublic))).Methods(http.MethodGet)
|
|
|
|
h.Handle("/settings/authentication/checkLDAP",
|
|
|
|
bouncer.AdministratorAccess(httperror.LoggerHandler(h.settingsLDAPCheck))).Methods(http.MethodPut)
|
|
|
|
|
|
|
|
return h
|
|
|
|
}
|