2018-06-11 13:13:19 +00:00
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
2019-01-16 15:25:16 +00:00
|
|
|
"fmt"
|
2018-06-11 13:13:19 +00:00
|
|
|
"net/http"
|
|
|
|
|
2018-09-10 10:01:38 +00:00
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
|
|
"github.com/portainer/libhttp/response"
|
2020-07-27 07:11:32 +00:00
|
|
|
portainer "github.com/portainer/portainer/api"
|
2018-06-11 13:13:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type publicSettingsResponse struct {
|
2020-07-28 07:08:15 +00:00
|
|
|
LogoURL string `json:"LogoURL"`
|
|
|
|
AuthenticationMethod portainer.AuthenticationMethod `json:"AuthenticationMethod"`
|
|
|
|
AllowBindMountsForRegularUsers bool `json:"AllowBindMountsForRegularUsers"`
|
|
|
|
AllowPrivilegedModeForRegularUsers bool `json:"AllowPrivilegedModeForRegularUsers"`
|
|
|
|
AllowVolumeBrowserForRegularUsers bool `json:"AllowVolumeBrowserForRegularUsers"`
|
|
|
|
AllowHostNamespaceForRegularUsers bool `json:"AllowHostNamespaceForRegularUsers"`
|
|
|
|
AllowDeviceMappingForRegularUsers bool `json:"AllowDeviceMappingForRegularUsers"`
|
|
|
|
AllowStackManagementForRegularUsers bool `json:"AllowStackManagementForRegularUsers"`
|
|
|
|
AllowContainerCapabilitiesForRegularUsers bool `json:"AllowContainerCapabilitiesForRegularUsers"`
|
|
|
|
EnableHostManagementFeatures bool `json:"EnableHostManagementFeatures"`
|
|
|
|
EnableEdgeComputeFeatures bool `json:"EnableEdgeComputeFeatures"`
|
|
|
|
OAuthLoginURI string `json:"OAuthLoginURI"`
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GET request on /api/settings/public
|
|
|
|
func (handler *Handler) settingsPublic(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
2020-05-20 05:23:15 +00:00
|
|
|
settings, err := handler.DataStore.Settings().Settings()
|
2018-06-11 13:13:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve the settings from the database", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
publicSettings := &publicSettingsResponse{
|
2020-07-28 07:08:15 +00:00
|
|
|
LogoURL: settings.LogoURL,
|
|
|
|
AuthenticationMethod: settings.AuthenticationMethod,
|
|
|
|
AllowBindMountsForRegularUsers: settings.AllowBindMountsForRegularUsers,
|
|
|
|
AllowPrivilegedModeForRegularUsers: settings.AllowPrivilegedModeForRegularUsers,
|
|
|
|
AllowVolumeBrowserForRegularUsers: settings.AllowVolumeBrowserForRegularUsers,
|
|
|
|
AllowHostNamespaceForRegularUsers: settings.AllowHostNamespaceForRegularUsers,
|
|
|
|
AllowDeviceMappingForRegularUsers: settings.AllowDeviceMappingForRegularUsers,
|
|
|
|
AllowStackManagementForRegularUsers: settings.AllowStackManagementForRegularUsers,
|
|
|
|
AllowContainerCapabilitiesForRegularUsers: settings.AllowContainerCapabilitiesForRegularUsers,
|
|
|
|
EnableHostManagementFeatures: settings.EnableHostManagementFeatures,
|
|
|
|
EnableEdgeComputeFeatures: settings.EnableEdgeComputeFeatures,
|
2019-02-21 01:02:25 +00:00
|
|
|
OAuthLoginURI: fmt.Sprintf("%s?response_type=code&client_id=%s&redirect_uri=%s&scope=%s&prompt=login",
|
2019-01-16 15:25:16 +00:00
|
|
|
settings.OAuthSettings.AuthorizationURI,
|
|
|
|
settings.OAuthSettings.ClientID,
|
|
|
|
settings.OAuthSettings.RedirectURI,
|
|
|
|
settings.OAuthSettings.Scopes),
|
2018-08-07 15:43:36 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 13:13:19 +00:00
|
|
|
return response.JSON(w, publicSettings)
|
|
|
|
}
|