2018-06-11 15:13:19 +02:00
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
2019-01-16 17:25:16 +02:00
|
|
|
"fmt"
|
2018-06-11 15:13:19 +02:00
|
|
|
"net/http"
|
|
|
|
|
2018-09-10 12:01:38 +02:00
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
|
|
"github.com/portainer/libhttp/response"
|
2020-07-27 10:11:32 +03:00
|
|
|
portainer "github.com/portainer/portainer/api"
|
2018-06-11 15:13:19 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type publicSettingsResponse struct {
|
2021-02-23 05:21:39 +02:00
|
|
|
// URL to a logo that will be displayed on the login page as well as on top of the sidebar. Will use default Portainer logo when value is empty string
|
|
|
|
LogoURL string `json:"LogoURL" example:"https://mycompany.mydomain.tld/logo.png"`
|
|
|
|
// Active authentication method for the Portainer instance. Valid values are: 1 for internal, 2 for LDAP, or 3 for oauth
|
|
|
|
AuthenticationMethod portainer.AuthenticationMethod `json:"AuthenticationMethod" example:"1"`
|
|
|
|
// Whether edge compute features are enabled
|
|
|
|
EnableEdgeComputeFeatures bool `json:"EnableEdgeComputeFeatures" example:"true"`
|
|
|
|
// The URL used for oauth login
|
|
|
|
OAuthLoginURI string `json:"OAuthLoginURI" example:"https://gitlab.com/oauth"`
|
|
|
|
// Whether telemetry is enabled
|
|
|
|
EnableTelemetry bool `json:"EnableTelemetry" example:"true"`
|
2018-06-11 15:13:19 +02:00
|
|
|
}
|
|
|
|
|
2021-02-23 05:21:39 +02:00
|
|
|
// @id SettingsPublic
|
|
|
|
// @summary Retrieve Portainer public settings
|
|
|
|
// @description Retrieve public settings. Returns a small set of settings that are not reserved to administrators only.
|
|
|
|
// @description **Access policy**: public
|
|
|
|
// @tags settings
|
|
|
|
// @produce json
|
|
|
|
// @success 200 {object} publicSettingsResponse "Success"
|
|
|
|
// @failure 500 "Server error"
|
|
|
|
// @router /settings/public [get]
|
2018-06-11 15:13:19 +02:00
|
|
|
func (handler *Handler) settingsPublic(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
2020-05-20 17:23:15 +12:00
|
|
|
settings, err := handler.DataStore.Settings().Settings()
|
2018-06-11 15:13:19 +02:00
|
|
|
if err != nil {
|
|
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve the settings from the database", err}
|
|
|
|
}
|
|
|
|
|
|
|
|
publicSettings := &publicSettingsResponse{
|
2021-02-09 10:09:06 +02:00
|
|
|
LogoURL: settings.LogoURL,
|
|
|
|
AuthenticationMethod: settings.AuthenticationMethod,
|
|
|
|
EnableEdgeComputeFeatures: settings.EnableEdgeComputeFeatures,
|
|
|
|
EnableTelemetry: settings.EnableTelemetry,
|
2019-02-21 14:02:25 +13:00
|
|
|
OAuthLoginURI: fmt.Sprintf("%s?response_type=code&client_id=%s&redirect_uri=%s&scope=%s&prompt=login",
|
2019-01-16 17:25:16 +02:00
|
|
|
settings.OAuthSettings.AuthorizationURI,
|
|
|
|
settings.OAuthSettings.ClientID,
|
|
|
|
settings.OAuthSettings.RedirectURI,
|
|
|
|
settings.OAuthSettings.Scopes),
|
2018-08-07 17:43:36 +02:00
|
|
|
}
|
|
|
|
|
2018-06-11 15:13:19 +02:00
|
|
|
return response.JSON(w, publicSettings)
|
|
|
|
}
|