mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 14:59:41 +02:00
* feat(endpoint): migrate security settings to endpoint * feat(endpoint): check for specific endpoint settings * feat(endpoint): check security settings * feat(docker): add config page * feat(endpoint): save settings page * feat(endpoints): disable features when not agent * feat(sidebar): hide docker settings for regular user * fix(docker): small fixes in configs * fix(volumes): hide browse button for non admins * refactor(docker): introduce switch component * refactor(components/switch): seprate label from switch * feat(app/components): align switch label * refactor(app/components): move switch css * fix(docker/settings): add ngijnect * feat(endpoints): set default security values * style(portainer): sort types * fix(endpoint): rename security heading * fix(endpoints): update endpoints settings
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package settings
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/libhttp/response"
|
|
portainer "github.com/portainer/portainer/api"
|
|
)
|
|
|
|
type publicSettingsResponse struct {
|
|
LogoURL string `json:"LogoURL"`
|
|
AuthenticationMethod portainer.AuthenticationMethod `json:"AuthenticationMethod"`
|
|
EnableEdgeComputeFeatures bool `json:"EnableEdgeComputeFeatures"`
|
|
OAuthLoginURI string `json:"OAuthLoginURI"`
|
|
EnableTelemetry bool `json:"EnableTelemetry"`
|
|
}
|
|
|
|
// GET request on /api/settings/public
|
|
func (handler *Handler) settingsPublic(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
settings, err := handler.DataStore.Settings().Settings()
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve the settings from the database", err}
|
|
}
|
|
|
|
publicSettings := &publicSettingsResponse{
|
|
LogoURL: settings.LogoURL,
|
|
AuthenticationMethod: settings.AuthenticationMethod,
|
|
EnableEdgeComputeFeatures: settings.EnableEdgeComputeFeatures,
|
|
EnableTelemetry: settings.EnableTelemetry,
|
|
OAuthLoginURI: fmt.Sprintf("%s?response_type=code&client_id=%s&redirect_uri=%s&scope=%s&prompt=login",
|
|
settings.OAuthSettings.AuthorizationURI,
|
|
settings.OAuthSettings.ClientID,
|
|
settings.OAuthSettings.RedirectURI,
|
|
settings.OAuthSettings.Scopes),
|
|
}
|
|
|
|
return response.JSON(w, publicSettings)
|
|
}
|