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"
|
2019-03-21 01:20:14 +00:00
|
|
|
"github.com/portainer/portainer/api"
|
|
|
|
"github.com/portainer/portainer/api/http/security"
|
2018-06-11 13:13:19 +00:00
|
|
|
)
|
|
|
|
|
2018-11-23 19:40:56 +00:00
|
|
|
func hideFields(settings *portainer.Settings) {
|
|
|
|
settings.LDAPSettings.Password = ""
|
2018-12-30 16:02:22 +00:00
|
|
|
settings.OAuthSettings.ClientSecret = ""
|
2018-11-23 19:40:56 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
// Handler is the HTTP handler used to handle settings operations.
|
|
|
|
type Handler struct {
|
|
|
|
*mux.Router
|
2020-06-09 09:55:36 +00:00
|
|
|
AuthorizationService *portainer.AuthorizationService
|
2020-05-20 05:23:15 +00:00
|
|
|
DataStore portainer.DataStore
|
2019-10-08 00:17:58 +00:00
|
|
|
FileService portainer.FileService
|
|
|
|
JobScheduler portainer.JobScheduler
|
2020-06-09 09:55:36 +00:00
|
|
|
JWTService portainer.JWTService
|
|
|
|
LDAPService portainer.LDAPService
|
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",
|
2019-10-07 03:10:51 +00:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.settingsInspect))).Methods(http.MethodGet)
|
2018-06-11 13:13:19 +00:00
|
|
|
h.Handle("/settings",
|
2019-10-07 03:10:51 +00:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.settingsUpdate))).Methods(http.MethodPut)
|
2018-06-11 13:13:19 +00:00
|
|
|
h.Handle("/settings/public",
|
|
|
|
bouncer.PublicAccess(httperror.LoggerHandler(h.settingsPublic))).Methods(http.MethodGet)
|
|
|
|
h.Handle("/settings/authentication/checkLDAP",
|
2019-10-07 03:10:51 +00:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.settingsLDAPCheck))).Methods(http.MethodPut)
|
2018-06-11 13:13:19 +00:00
|
|
|
|
|
|
|
return h
|
|
|
|
}
|