2014-12-29 06:36:08 -06:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2021-11-02 07:42:55 -05:00
|
|
|
"context"
|
2023-01-27 08:08:17 -06:00
|
|
|
"fmt"
|
2022-04-15 07:01:58 -05:00
|
|
|
"net/http"
|
2023-11-01 11:17:38 -05:00
|
|
|
"slices"
|
2023-04-27 11:20:37 -05:00
|
|
|
"strings"
|
2014-12-29 06:36:08 -06:00
|
|
|
|
2023-01-31 13:14:15 -06:00
|
|
|
"github.com/grafana/grafana/pkg/api/dtos"
|
2015-02-27 15:29:00 -06:00
|
|
|
"github.com/grafana/grafana/pkg/plugins"
|
2021-10-05 08:54:26 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
2023-01-27 01:50:36 -06:00
|
|
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
2022-06-27 11:23:15 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/datasources"
|
2023-05-22 07:34:41 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
2023-12-05 09:13:31 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/folder"
|
2022-03-16 08:37:19 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/licensing"
|
2023-03-07 10:22:30 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginsettings"
|
2023-09-11 06:59:24 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore"
|
2022-08-10 14:47:03 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/secrets/kvstore"
|
2015-02-05 03:37:13 -06:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
2021-10-05 08:54:26 -05:00
|
|
|
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
|
|
|
"github.com/grafana/grafana/pkg/util"
|
2014-12-29 06:36:08 -06:00
|
|
|
)
|
|
|
|
|
2023-01-27 01:50:36 -06:00
|
|
|
func (hs *HTTPServer) GetFrontendSettings(c *contextmodel.ReqContext) {
|
2023-01-31 13:14:15 -06:00
|
|
|
settings, err := hs.getFrontendSettings(c)
|
2022-03-18 14:49:13 -05:00
|
|
|
if err != nil {
|
|
|
|
c.JsonApiErr(400, "Failed to get frontend settings", err)
|
|
|
|
return
|
2015-08-16 13:52:30 -05:00
|
|
|
}
|
2015-02-28 02:46:37 -06:00
|
|
|
|
2022-04-15 07:01:58 -05:00
|
|
|
c.JSON(http.StatusOK, settings)
|
2020-09-07 15:10:06 -05:00
|
|
|
}
|
|
|
|
|
2023-01-31 13:14:15 -06:00
|
|
|
// getFrontendSettings returns a json object with all the settings needed for front end initialisation.
|
|
|
|
func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.FrontendSettingsDTO, error) {
|
2023-10-06 04:34:36 -05:00
|
|
|
availablePlugins, err := hs.availablePlugins(c.Req.Context(), c.SignedInUser.GetOrgID())
|
2020-09-07 15:10:06 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-02-25 03:00:21 -06:00
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
apps := make(map[string]*plugins.AppDTO, 0)
|
2023-06-08 05:21:19 -05:00
|
|
|
for _, ap := range availablePlugins[plugins.TypeApp] {
|
2023-02-07 10:20:05 -06:00
|
|
|
apps[ap.Plugin.ID] = newAppDTO(
|
|
|
|
ap.Plugin,
|
|
|
|
ap.Settings,
|
|
|
|
)
|
2020-09-07 15:10:06 -05:00
|
|
|
}
|
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
dataSources, err := hs.getFSDataSources(c, availablePlugins)
|
2020-09-07 15:10:06 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultDS := "-- Grafana --"
|
|
|
|
for n, ds := range dataSources {
|
2021-12-14 04:16:13 -06:00
|
|
|
if ds.IsDefault {
|
2020-09-07 15:10:06 -05:00
|
|
|
defaultDS = n
|
|
|
|
}
|
2014-12-29 06:36:08 -06:00
|
|
|
}
|
|
|
|
|
2021-12-14 04:16:13 -06:00
|
|
|
panels := make(map[string]plugins.PanelDTO)
|
2023-06-08 05:21:19 -05:00
|
|
|
for _, ap := range availablePlugins[plugins.TypePanel] {
|
2023-02-07 10:20:05 -06:00
|
|
|
panel := ap.Plugin
|
2023-06-08 05:21:19 -05:00
|
|
|
if panel.State == plugins.ReleaseStateAlpha && !hs.Cfg.PluginsEnableAlpha {
|
2018-10-09 10:47:43 -05:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2023-11-14 14:50:27 -06:00
|
|
|
if panel.ID == "datagrid" && !hs.Features.IsEnabled(c.Req.Context(), featuremgmt.FlagEnableDatagridEditing) {
|
2023-05-22 07:34:41 -05:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2021-12-14 04:16:13 -06:00
|
|
|
panels[panel.ID] = plugins.PanelDTO{
|
2023-11-10 04:44:54 -06:00
|
|
|
ID: panel.ID,
|
|
|
|
Name: panel.Name,
|
|
|
|
AliasIDs: panel.AliasIDs,
|
|
|
|
Info: panel.Info,
|
|
|
|
Module: panel.Module,
|
|
|
|
BaseURL: panel.BaseURL,
|
|
|
|
SkipDataQuery: panel.SkipDataQuery,
|
|
|
|
HideFromList: panel.HideFromList,
|
|
|
|
ReleaseState: string(panel.State),
|
|
|
|
Signature: string(panel.Signature),
|
|
|
|
Sort: getPanelSort(panel.ID),
|
|
|
|
Angular: panel.Angular,
|
2015-11-21 06:46:18 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-17 00:39:50 -05:00
|
|
|
hideVersion := hs.Cfg.AnonymousHideVersion && !c.IsSignedIn
|
|
|
|
version := setting.BuildVersion
|
|
|
|
commit := setting.BuildCommit
|
|
|
|
buildstamp := setting.BuildStamp
|
|
|
|
|
|
|
|
if hideVersion {
|
|
|
|
version = ""
|
|
|
|
commit = ""
|
|
|
|
buildstamp = 0
|
|
|
|
}
|
|
|
|
|
2021-10-05 08:54:26 -05:00
|
|
|
hasAccess := accesscontrol.HasAccess(hs.AccessControl, c)
|
2022-09-02 07:20:10 -05:00
|
|
|
secretsManagerPluginEnabled := kvstore.EvaluateRemoteSecretsPlugin(c.Req.Context(), hs.secretsPluginManager, hs.Cfg) == nil
|
2023-04-27 11:20:37 -05:00
|
|
|
trustedTypesDefaultPolicyEnabled := (hs.Cfg.CSPEnabled && strings.Contains(hs.Cfg.CSPTemplate, "require-trusted-types-for")) || (hs.Cfg.CSPReportOnlyEnabled && strings.Contains(hs.Cfg.CSPReportOnlyTemplate, "require-trusted-types-for"))
|
2021-10-05 08:54:26 -05:00
|
|
|
|
2023-01-31 13:14:15 -06:00
|
|
|
frontendSettings := &dtos.FrontendSettingsDTO{
|
|
|
|
DefaultDatasource: defaultDS,
|
|
|
|
Datasources: dataSources,
|
|
|
|
MinRefreshInterval: setting.MinRefreshInterval,
|
|
|
|
Panels: panels,
|
2023-02-07 10:20:05 -06:00
|
|
|
Apps: apps,
|
2023-01-31 13:14:15 -06:00
|
|
|
AppUrl: hs.Cfg.AppURL,
|
|
|
|
AppSubUrl: hs.Cfg.AppSubURL,
|
|
|
|
AllowOrgCreate: (setting.AllowUserOrgCreate && c.IsSignedIn) || c.IsGrafanaAdmin,
|
2023-02-27 08:28:49 -06:00
|
|
|
AuthProxyEnabled: hs.Cfg.AuthProxyEnabled,
|
2023-03-22 12:41:59 -05:00
|
|
|
LdapEnabled: hs.Cfg.LDAPAuthEnabled,
|
2023-01-31 13:14:15 -06:00
|
|
|
JwtHeaderName: hs.Cfg.JWTAuthHeaderName,
|
|
|
|
JwtUrlLogin: hs.Cfg.JWTAuthURLLogin,
|
|
|
|
AlertingErrorOrTimeout: setting.AlertingErrorOrTimeout,
|
|
|
|
AlertingNoDataOrNullValues: setting.AlertingNoDataOrNullValues,
|
|
|
|
AlertingMinInterval: setting.AlertingMinInterval,
|
|
|
|
LiveEnabled: hs.Cfg.LiveMaxConnections != 0,
|
2023-02-27 03:23:38 -06:00
|
|
|
AutoAssignOrg: hs.Cfg.AutoAssignOrg,
|
2023-01-31 13:14:15 -06:00
|
|
|
VerifyEmailEnabled: setting.VerifyEmailEnabled,
|
|
|
|
SigV4AuthEnabled: setting.SigV4AuthEnabled,
|
|
|
|
AzureAuthEnabled: setting.AzureAuthEnabled,
|
2023-09-05 05:04:39 -05:00
|
|
|
RbacEnabled: true,
|
2023-01-31 13:14:15 -06:00
|
|
|
ExploreEnabled: setting.ExploreEnabled,
|
|
|
|
HelpEnabled: setting.HelpEnabled,
|
|
|
|
ProfileEnabled: setting.ProfileEnabled,
|
2023-06-01 07:35:05 -05:00
|
|
|
NewsFeedEnabled: setting.NewsFeedEnabled,
|
2023-01-31 13:14:15 -06:00
|
|
|
QueryHistoryEnabled: hs.Cfg.QueryHistoryEnabled,
|
2023-02-21 04:19:07 -06:00
|
|
|
GoogleAnalyticsId: hs.Cfg.GoogleAnalyticsID,
|
|
|
|
GoogleAnalytics4Id: hs.Cfg.GoogleAnalytics4ID,
|
|
|
|
GoogleAnalytics4SendManualPageViews: hs.Cfg.GoogleAnalytics4SendManualPageViews,
|
|
|
|
RudderstackWriteKey: hs.Cfg.RudderstackWriteKey,
|
|
|
|
RudderstackDataPlaneUrl: hs.Cfg.RudderstackDataPlaneURL,
|
|
|
|
RudderstackSdkUrl: hs.Cfg.RudderstackSDKURL,
|
|
|
|
RudderstackConfigUrl: hs.Cfg.RudderstackConfigURL,
|
2023-10-23 07:43:33 -05:00
|
|
|
RudderstackIntegrationsUrl: hs.Cfg.RudderstackIntegrationsURL,
|
2023-01-31 13:14:15 -06:00
|
|
|
FeedbackLinksEnabled: hs.Cfg.FeedbackLinksEnabled,
|
|
|
|
ApplicationInsightsConnectionString: hs.Cfg.ApplicationInsightsConnectionString,
|
|
|
|
ApplicationInsightsEndpointUrl: hs.Cfg.ApplicationInsightsEndpointUrl,
|
2023-02-27 08:28:49 -06:00
|
|
|
DisableLoginForm: hs.Cfg.DisableLoginForm,
|
2023-01-31 13:14:15 -06:00
|
|
|
DisableUserSignUp: !setting.AllowUserSignUp,
|
|
|
|
LoginHint: setting.LoginHint,
|
|
|
|
PasswordHint: setting.PasswordHint,
|
|
|
|
ExternalUserMngInfo: setting.ExternalUserMngInfo,
|
|
|
|
ExternalUserMngLinkUrl: setting.ExternalUserMngLinkUrl,
|
|
|
|
ExternalUserMngLinkName: setting.ExternalUserMngLinkName,
|
2023-03-16 04:54:01 -05:00
|
|
|
ViewersCanEdit: hs.Cfg.ViewersCanEdit,
|
2023-01-31 13:14:15 -06:00
|
|
|
AngularSupportEnabled: hs.Cfg.AngularSupportEnabled,
|
|
|
|
EditorsCanAdmin: hs.Cfg.EditorsCanAdmin,
|
|
|
|
DisableSanitizeHtml: hs.Cfg.DisableSanitizeHtml,
|
2023-04-27 11:20:37 -05:00
|
|
|
TrustedTypesDefaultPolicyEnabled: trustedTypesDefaultPolicyEnabled,
|
|
|
|
CSPReportOnlyEnabled: hs.Cfg.CSPReportOnlyEnabled,
|
2023-01-31 13:14:15 -06:00
|
|
|
DateFormats: hs.Cfg.DateFormats,
|
2023-06-01 13:58:51 -05:00
|
|
|
SecureSocksDSProxyEnabled: hs.Cfg.SecureSocksDSProxy.Enabled && hs.Cfg.SecureSocksDSProxy.ShowUI,
|
2023-07-05 04:16:56 -05:00
|
|
|
DisableFrontendSandboxForPlugins: hs.Cfg.DisableFrontendSandboxForPlugins,
|
2023-08-25 13:56:02 -05:00
|
|
|
PublicDashboardAccessToken: c.PublicDashboardAccessToken,
|
2023-12-05 09:13:31 -06:00
|
|
|
SharedWithMeFolderUID: folder.SharedWithMeFolderUID,
|
2023-01-31 13:14:15 -06:00
|
|
|
|
|
|
|
Auth: dtos.FrontendSettingsAuthDTO{
|
2023-02-01 10:27:53 -06:00
|
|
|
OAuthSkipOrgRoleUpdateSync: hs.Cfg.OAuthSkipOrgRoleUpdateSync,
|
2023-02-08 14:11:46 -06:00
|
|
|
SAMLSkipOrgRoleSync: hs.Cfg.SAMLSkipOrgRoleSync,
|
2023-02-01 10:27:53 -06:00
|
|
|
LDAPSkipOrgRoleSync: hs.Cfg.LDAPSkipOrgRoleSync,
|
|
|
|
GoogleSkipOrgRoleSync: hs.Cfg.GoogleSkipOrgRoleSync,
|
|
|
|
JWTAuthSkipOrgRoleSync: hs.Cfg.JWTAuthSkipOrgRoleSync,
|
|
|
|
GrafanaComSkipOrgRoleSync: hs.Cfg.GrafanaComSkipOrgRoleSync,
|
|
|
|
GenericOAuthSkipOrgRoleSync: hs.Cfg.GenericOAuthSkipOrgRoleSync,
|
|
|
|
AzureADSkipOrgRoleSync: hs.Cfg.AzureADSkipOrgRoleSync,
|
2023-03-22 12:41:59 -05:00
|
|
|
GithubSkipOrgRoleSync: hs.Cfg.GitHubSkipOrgRoleSync,
|
2023-02-01 10:27:53 -06:00
|
|
|
GitLabSkipOrgRoleSync: hs.Cfg.GitLabSkipOrgRoleSync,
|
|
|
|
OktaSkipOrgRoleSync: hs.Cfg.OktaSkipOrgRoleSync,
|
2023-07-28 08:32:58 -05:00
|
|
|
AuthProxyEnableLoginToken: hs.Cfg.AuthProxyEnableLoginToken,
|
2022-09-15 11:06:09 -05:00
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
|
|
|
|
BuildInfo: dtos.FrontendSettingsBuildInfoDTO{
|
|
|
|
HideVersion: hideVersion,
|
|
|
|
Version: version,
|
|
|
|
Commit: commit,
|
|
|
|
Buildstamp: buildstamp,
|
|
|
|
Edition: hs.License.Edition(),
|
|
|
|
LatestVersion: hs.grafanaUpdateChecker.LatestVersion(),
|
|
|
|
HasUpdate: hs.grafanaUpdateChecker.UpdateAvailable(),
|
|
|
|
Env: setting.Env,
|
2019-11-01 08:56:12 -05:00
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
|
|
|
|
LicenseInfo: dtos.FrontendSettingsLicenseInfoDTO{
|
|
|
|
Expiry: hs.License.Expiry(),
|
|
|
|
StateInfo: hs.License.StateInfo(),
|
2023-05-30 08:39:09 -05:00
|
|
|
LicenseUrl: hs.License.LicenseURL(hasAccess(licensing.PageAccess)),
|
2023-01-31 13:14:15 -06:00
|
|
|
Edition: hs.License.Edition(),
|
|
|
|
EnabledFeatures: hs.License.EnabledFeatures(),
|
2015-01-05 03:46:58 -06:00
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
|
|
|
|
FeatureToggles: hs.Features.GetEnabled(c.Req.Context()),
|
2023-03-09 10:42:45 -06:00
|
|
|
AnonymousEnabled: hs.Cfg.AnonymousEnabled,
|
2023-01-31 13:14:15 -06:00
|
|
|
RendererAvailable: hs.RenderService.IsAvailable(c.Req.Context()),
|
|
|
|
RendererVersion: hs.RenderService.Version(),
|
|
|
|
SecretsManagerPluginEnabled: secretsManagerPluginEnabled,
|
|
|
|
Http2Enabled: hs.Cfg.Protocol == setting.HTTP2Scheme,
|
|
|
|
GrafanaJavascriptAgent: hs.Cfg.GrafanaJavascriptAgent,
|
|
|
|
PluginCatalogURL: hs.Cfg.PluginCatalogURL,
|
|
|
|
PluginAdminEnabled: hs.Cfg.PluginAdminEnabled,
|
|
|
|
PluginAdminExternalManageEnabled: hs.Cfg.PluginAdminEnabled && hs.Cfg.PluginAdminExternalManageEnabled,
|
|
|
|
PluginCatalogHiddenPlugins: hs.Cfg.PluginCatalogHiddenPlugins,
|
|
|
|
ExpressionsEnabled: hs.Cfg.ExpressionsEnabled,
|
|
|
|
AwsAllowedAuthProviders: hs.Cfg.AWSAllowedAuthProviders,
|
|
|
|
AwsAssumeRoleEnabled: hs.Cfg.AWSAssumeRoleEnabled,
|
|
|
|
SupportBundlesEnabled: isSupportBundlesEnabled(hs),
|
|
|
|
|
|
|
|
Azure: dtos.FrontendSettingsAzureDTO{
|
2023-09-28 06:05:16 -05:00
|
|
|
Cloud: hs.Cfg.Azure.Cloud,
|
|
|
|
ManagedIdentityEnabled: hs.Cfg.Azure.ManagedIdentityEnabled,
|
|
|
|
WorkloadIdentityEnabled: hs.Cfg.Azure.WorkloadIdentityEnabled,
|
|
|
|
UserIdentityEnabled: hs.Cfg.Azure.UserIdentityEnabled,
|
2021-05-12 09:23:37 -05:00
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
|
|
|
|
Caching: dtos.FrontendSettingsCachingDTO{
|
|
|
|
Enabled: hs.Cfg.SectionWithEnvOverrides("caching").Key("enabled").MustBool(true),
|
2021-05-26 12:27:28 -05:00
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
RecordedQueries: dtos.FrontendSettingsRecordedQueriesDTO{
|
|
|
|
Enabled: hs.Cfg.SectionWithEnvOverrides("recorded_queries").Key("enabled").MustBool(true),
|
2021-11-17 15:45:05 -06:00
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
Reporting: dtos.FrontendSettingsReportingDTO{
|
|
|
|
Enabled: hs.Cfg.SectionWithEnvOverrides("reporting").Key("enabled").MustBool(true),
|
2022-03-22 15:30:45 -05:00
|
|
|
},
|
2023-11-09 04:53:20 -06:00
|
|
|
Analytics: dtos.FrontendSettingsAnalyticsDTO{
|
|
|
|
Enabled: hs.Cfg.SectionWithEnvOverrides("analytics").Key("enabled").MustBool(true),
|
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
|
|
|
|
UnifiedAlerting: dtos.FrontendSettingsUnifiedAlertingDTO{
|
|
|
|
MinInterval: hs.Cfg.UnifiedAlerting.MinInterval.String(),
|
2022-08-01 08:01:14 -05:00
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
|
|
|
|
Oauth: hs.getEnabledOAuthProviders(),
|
|
|
|
SamlEnabled: hs.samlEnabled(),
|
|
|
|
SamlName: hs.samlName(),
|
|
|
|
TokenExpirationDayLimit: hs.Cfg.SATokenExpirationDayLimit,
|
|
|
|
|
|
|
|
SnapshotEnabled: hs.Cfg.SnapshotEnabled,
|
2023-04-28 01:23:08 -05:00
|
|
|
|
|
|
|
SqlConnectionLimits: dtos.FrontendSettingsSqlConnectionLimitsDTO{
|
|
|
|
MaxOpenConns: hs.Cfg.SqlDatasourceMaxOpenConnsDefault,
|
|
|
|
MaxIdleConns: hs.Cfg.SqlDatasourceMaxIdleConnsDefault,
|
|
|
|
ConnMaxLifetime: hs.Cfg.SqlDatasourceMaxConnLifetimeDefault,
|
|
|
|
},
|
2023-01-31 13:14:15 -06:00
|
|
|
}
|
|
|
|
|
2023-04-24 02:28:11 -05:00
|
|
|
if hs.Cfg.UnifiedAlerting.StateHistory.Enabled {
|
|
|
|
frontendSettings.UnifiedAlerting.AlertStateHistoryBackend = hs.Cfg.UnifiedAlerting.StateHistory.Backend
|
2023-05-25 08:09:44 -05:00
|
|
|
frontendSettings.UnifiedAlerting.AlertStateHistoryPrimary = hs.Cfg.UnifiedAlerting.StateHistory.MultiPrimary
|
2023-04-24 02:28:11 -05:00
|
|
|
}
|
|
|
|
|
2023-01-31 13:14:15 -06:00
|
|
|
if hs.Cfg.UnifiedAlerting.Enabled != nil {
|
|
|
|
frontendSettings.UnifiedAlertingEnabled = *hs.Cfg.UnifiedAlerting.Enabled
|
|
|
|
}
|
|
|
|
|
|
|
|
if setting.AlertingEnabled != nil {
|
|
|
|
frontendSettings.AlertingEnabled = *setting.AlertingEnabled
|
2021-07-21 15:48:20 -05:00
|
|
|
}
|
|
|
|
|
2023-01-27 08:08:17 -06:00
|
|
|
if hs.pluginsCDNService != nil && hs.pluginsCDNService.IsEnabled() {
|
|
|
|
cdnBaseURL, err := hs.pluginsCDNService.BaseURL()
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("plugins cdn base url: %w", err)
|
|
|
|
}
|
2023-01-31 13:14:15 -06:00
|
|
|
frontendSettings.PluginsCDNBaseURL = cdnBaseURL
|
2023-01-27 08:08:17 -06:00
|
|
|
}
|
|
|
|
|
2021-07-21 15:48:20 -05:00
|
|
|
if hs.Cfg.GeomapDefaultBaseLayerConfig != nil {
|
2023-01-31 13:14:15 -06:00
|
|
|
frontendSettings.GeomapDefaultBaseLayerConfig = &hs.Cfg.GeomapDefaultBaseLayerConfig
|
2021-07-21 15:48:20 -05:00
|
|
|
}
|
2023-01-31 13:14:15 -06:00
|
|
|
|
2021-07-21 15:48:20 -05:00
|
|
|
if !hs.Cfg.GeomapEnableCustomBaseLayers {
|
2023-01-31 13:14:15 -06:00
|
|
|
frontendSettings.GeomapDisableCustomBaseLayer = true
|
2014-12-29 06:36:08 -06:00
|
|
|
}
|
|
|
|
|
2023-11-13 22:34:09 -06:00
|
|
|
// Set the kubernetes namespace
|
|
|
|
frontendSettings.Namespace = hs.namespacer(c.SignedInUser.OrgID)
|
|
|
|
|
2023-01-31 13:14:15 -06:00
|
|
|
return frontendSettings, nil
|
2014-12-29 06:36:08 -06:00
|
|
|
}
|
2015-02-18 07:06:44 -06:00
|
|
|
|
2023-01-23 10:23:20 -06:00
|
|
|
func isSupportBundlesEnabled(hs *HTTPServer) bool {
|
2023-02-10 03:12:04 -06:00
|
|
|
return hs.Cfg.SectionWithEnvOverrides("support_bundles").Key("enabled").MustBool(true)
|
2023-01-23 10:23:20 -06:00
|
|
|
}
|
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, availablePlugins AvailablePlugins) (map[string]plugins.DataSourceDTO, error) {
|
2022-06-27 11:23:15 -05:00
|
|
|
orgDataSources := make([]*datasources.DataSource, 0)
|
2023-10-06 04:34:36 -05:00
|
|
|
if c.SignedInUser.GetOrgID() != 0 {
|
|
|
|
query := datasources.GetDataSourcesQuery{OrgID: c.SignedInUser.GetOrgID(), DataSourceLimit: hs.Cfg.DataSourceLimit}
|
2023-02-09 08:49:44 -06:00
|
|
|
dataSources, err := hs.DataSourcesService.GetDataSources(c.Req.Context(), &query)
|
2022-03-18 14:49:13 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-08-25 13:56:02 -05:00
|
|
|
if c.IsPublicDashboardView() {
|
2022-10-18 14:44:33 -05:00
|
|
|
// If RBAC is enabled, it will filter out all datasources for a public user, so we need to skip it
|
2023-02-09 08:49:44 -06:00
|
|
|
orgDataSources = dataSources
|
2022-10-18 14:44:33 -05:00
|
|
|
} else {
|
2023-08-21 08:26:49 -05:00
|
|
|
filtered, err := hs.dsGuardian.New(c.SignedInUser.OrgID, c.SignedInUser).FilterDatasourcesByQueryPermissions(dataSources)
|
2022-10-18 14:44:33 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
orgDataSources = filtered
|
2022-03-18 14:49:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dataSources := make(map[string]plugins.DataSourceDTO)
|
|
|
|
|
|
|
|
for _, ds := range orgDataSources {
|
2023-02-02 10:22:43 -06:00
|
|
|
url := ds.URL
|
2022-03-18 14:49:13 -05:00
|
|
|
|
2022-06-27 11:23:15 -05:00
|
|
|
if ds.Access == datasources.DS_ACCESS_PROXY {
|
2023-02-02 10:22:43 -06:00
|
|
|
url = "/api/datasources/proxy/uid/" + ds.UID
|
2022-03-18 14:49:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
dsDTO := plugins.DataSourceDTO{
|
2023-02-02 10:22:43 -06:00
|
|
|
ID: ds.ID,
|
|
|
|
UID: ds.UID,
|
2022-03-18 14:49:13 -05:00
|
|
|
Type: ds.Type,
|
|
|
|
Name: ds.Name,
|
|
|
|
URL: url,
|
|
|
|
IsDefault: ds.IsDefault,
|
|
|
|
Access: string(ds.Access),
|
2022-08-26 05:27:28 -05:00
|
|
|
ReadOnly: ds.ReadOnly,
|
2022-03-18 14:49:13 -05:00
|
|
|
}
|
|
|
|
|
2023-06-08 05:21:19 -05:00
|
|
|
ap, exists := availablePlugins.Get(plugins.TypeDataSource, ds.Type)
|
2022-03-18 14:49:13 -05:00
|
|
|
if !exists {
|
|
|
|
c.Logger.Error("Could not find plugin definition for data source", "datasource_type", ds.Type)
|
|
|
|
continue
|
|
|
|
}
|
2023-02-07 10:20:05 -06:00
|
|
|
plugin := ap.Plugin
|
2023-06-02 12:46:12 -05:00
|
|
|
dsDTO.Type = plugin.ID
|
2022-03-18 14:49:13 -05:00
|
|
|
dsDTO.Preload = plugin.Preload
|
|
|
|
dsDTO.Module = plugin.Module
|
|
|
|
dsDTO.PluginMeta = &plugins.PluginMetaDTO{
|
|
|
|
JSONData: plugin.JSONData,
|
|
|
|
Signature: plugin.Signature,
|
|
|
|
Module: plugin.Module,
|
|
|
|
BaseURL: plugin.BaseURL,
|
2023-11-10 04:44:54 -06:00
|
|
|
Angular: plugin.Angular,
|
2022-03-18 14:49:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ds.JsonData == nil {
|
2023-08-30 10:46:47 -05:00
|
|
|
dsDTO.JSONData = make(map[string]any)
|
2022-03-18 14:49:13 -05:00
|
|
|
} else {
|
|
|
|
dsDTO.JSONData = ds.JsonData.MustMap()
|
|
|
|
}
|
|
|
|
|
2022-06-27 11:23:15 -05:00
|
|
|
if ds.Access == datasources.DS_ACCESS_DIRECT {
|
2022-03-18 14:49:13 -05:00
|
|
|
if ds.BasicAuth {
|
2022-04-25 11:57:45 -05:00
|
|
|
password, err := hs.DataSourcesService.DecryptedBasicAuthPassword(c.Req.Context(), ds)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-03-18 14:49:13 -05:00
|
|
|
dsDTO.BasicAuth = util.GetBasicAuthHeader(
|
|
|
|
ds.BasicAuthUser,
|
2022-04-25 11:57:45 -05:00
|
|
|
password,
|
2022-03-18 14:49:13 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
if ds.WithCredentials {
|
|
|
|
dsDTO.WithCredentials = ds.WithCredentials
|
|
|
|
}
|
|
|
|
|
2022-06-27 11:23:15 -05:00
|
|
|
if ds.Type == datasources.DS_INFLUXDB_08 {
|
2022-04-25 11:57:45 -05:00
|
|
|
password, err := hs.DataSourcesService.DecryptedPassword(c.Req.Context(), ds)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-03-18 14:49:13 -05:00
|
|
|
dsDTO.Username = ds.User
|
2022-04-25 11:57:45 -05:00
|
|
|
dsDTO.Password = password
|
2022-03-18 14:49:13 -05:00
|
|
|
dsDTO.URL = url + "/db/" + ds.Database
|
|
|
|
}
|
|
|
|
|
2022-06-27 11:23:15 -05:00
|
|
|
if ds.Type == datasources.DS_INFLUXDB {
|
2022-04-25 11:57:45 -05:00
|
|
|
password, err := hs.DataSourcesService.DecryptedPassword(c.Req.Context(), ds)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-03-18 14:49:13 -05:00
|
|
|
dsDTO.Username = ds.User
|
2022-04-25 11:57:45 -05:00
|
|
|
dsDTO.Password = password
|
2022-03-18 14:49:13 -05:00
|
|
|
dsDTO.URL = url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-06 11:28:52 -05:00
|
|
|
// Update `jsonData.database` for outdated provisioned SQL datasources created WITHOUT the `jsonData` object in their configuration.
|
|
|
|
// In these cases, the `Database` value is defined (if at all) on the root level of the provisioning config object.
|
|
|
|
// This is done for easier warning/error checking on the front end.
|
|
|
|
if (ds.Type == datasources.DS_MSSQL) || (ds.Type == datasources.DS_MYSQL) || (ds.Type == datasources.DS_POSTGRES) {
|
|
|
|
// Only update if the value isn't already assigned.
|
|
|
|
if dsDTO.JSONData["database"] == nil || dsDTO.JSONData["database"] == "" {
|
|
|
|
dsDTO.JSONData["database"] = ds.Database
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-27 11:23:15 -05:00
|
|
|
if (ds.Type == datasources.DS_INFLUXDB) || (ds.Type == datasources.DS_ES) {
|
2022-03-18 14:49:13 -05:00
|
|
|
dsDTO.Database = ds.Database
|
|
|
|
}
|
|
|
|
|
2022-06-27 11:23:15 -05:00
|
|
|
if ds.Type == datasources.DS_PROMETHEUS {
|
2022-03-18 14:49:13 -05:00
|
|
|
// add unproxied server URL for link to Prometheus web UI
|
2023-02-02 10:22:43 -06:00
|
|
|
ds.JsonData.Set("directUrl", ds.URL)
|
2022-03-18 14:49:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
dataSources[ds.Name] = dsDTO
|
|
|
|
}
|
|
|
|
|
|
|
|
// add data sources that are built in (meaning they are not added via data sources page, nor have any entry in
|
|
|
|
// the datasource table)
|
2023-06-08 05:21:19 -05:00
|
|
|
for _, ds := range hs.pluginStore.Plugins(c.Req.Context(), plugins.TypeDataSource) {
|
2022-03-18 14:49:13 -05:00
|
|
|
if ds.BuiltIn {
|
|
|
|
dto := plugins.DataSourceDTO{
|
|
|
|
Type: string(ds.Type),
|
|
|
|
Name: ds.Name,
|
2023-08-30 10:46:47 -05:00
|
|
|
JSONData: make(map[string]any),
|
2022-03-18 14:49:13 -05:00
|
|
|
PluginMeta: &plugins.PluginMetaDTO{
|
|
|
|
JSONData: ds.JSONData,
|
|
|
|
Signature: ds.Signature,
|
|
|
|
Module: ds.Module,
|
|
|
|
BaseURL: ds.BaseURL,
|
2023-11-10 04:44:54 -06:00
|
|
|
Angular: ds.Angular,
|
2022-03-18 14:49:13 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
if ds.Name == grafanads.DatasourceName {
|
|
|
|
dto.ID = grafanads.DatasourceID
|
|
|
|
dto.UID = grafanads.DatasourceUID
|
|
|
|
}
|
|
|
|
dataSources[ds.Name] = dto
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dataSources, nil
|
|
|
|
}
|
|
|
|
|
2023-09-11 06:59:24 -05:00
|
|
|
func newAppDTO(plugin pluginstore.Plugin, settings pluginsettings.InfoDTO) *plugins.AppDTO {
|
2023-02-07 10:20:05 -06:00
|
|
|
app := &plugins.AppDTO{
|
2023-11-10 04:44:54 -06:00
|
|
|
ID: plugin.ID,
|
|
|
|
Version: plugin.Info.Version,
|
|
|
|
Path: plugin.Module,
|
|
|
|
Preload: false,
|
|
|
|
Angular: plugin.Angular,
|
2023-02-07 10:20:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if settings.Enabled {
|
2023-02-08 07:41:49 -06:00
|
|
|
app.Preload = plugin.Preload
|
2023-02-07 10:20:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return app
|
|
|
|
}
|
|
|
|
|
2016-10-26 10:42:39 -05:00
|
|
|
func getPanelSort(id string) int {
|
|
|
|
sort := 100
|
|
|
|
switch id {
|
2021-01-10 10:41:20 -06:00
|
|
|
case "timeseries":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 1
|
2021-05-03 09:49:09 -05:00
|
|
|
case "barchart":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 2
|
2021-05-03 09:49:09 -05:00
|
|
|
case "stat":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 3
|
2021-05-03 09:49:09 -05:00
|
|
|
case "gauge":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 4
|
2021-05-03 09:49:09 -05:00
|
|
|
case "bargauge":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 5
|
2021-05-03 09:49:09 -05:00
|
|
|
case "table":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 6
|
2021-05-03 09:49:09 -05:00
|
|
|
case "singlestat":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 7
|
2021-05-03 09:49:09 -05:00
|
|
|
case "piechart":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 8
|
2021-05-17 15:00:04 -05:00
|
|
|
case "state-timeline":
|
2019-02-15 14:33:36 -06:00
|
|
|
sort = 9
|
2021-03-25 02:33:13 -05:00
|
|
|
case "heatmap":
|
2020-01-17 02:43:17 -06:00
|
|
|
sort = 10
|
2021-05-29 13:24:14 -05:00
|
|
|
case "status-history":
|
2021-01-10 10:41:20 -06:00
|
|
|
sort = 11
|
2021-05-20 10:36:20 -05:00
|
|
|
case "histogram":
|
2021-01-10 10:41:20 -06:00
|
|
|
sort = 12
|
2021-05-20 10:36:20 -05:00
|
|
|
case "graph":
|
2021-03-25 02:33:13 -05:00
|
|
|
sort = 13
|
2021-05-20 10:36:20 -05:00
|
|
|
case "text":
|
2021-05-03 09:49:09 -05:00
|
|
|
sort = 14
|
2021-05-20 10:36:20 -05:00
|
|
|
case "alertlist":
|
2021-05-05 06:19:14 -05:00
|
|
|
sort = 15
|
2021-05-20 10:36:20 -05:00
|
|
|
case "dashlist":
|
2021-05-17 15:00:04 -05:00
|
|
|
sort = 16
|
2021-05-20 10:36:20 -05:00
|
|
|
case "news":
|
|
|
|
sort = 17
|
2016-10-26 10:42:39 -05:00
|
|
|
}
|
|
|
|
return sort
|
|
|
|
}
|
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
type availablePluginDTO struct {
|
2023-09-11 06:59:24 -05:00
|
|
|
Plugin pluginstore.Plugin
|
2023-02-07 10:20:05 -06:00
|
|
|
Settings pluginsettings.InfoDTO
|
|
|
|
}
|
|
|
|
|
|
|
|
// AvailablePlugins represents a mapping from plugin types (panel, data source, etc.) to plugin IDs to plugins
|
2021-11-17 05:04:22 -06:00
|
|
|
// For example ["panel"] -> ["piechart"] -> {pie chart plugin DTO}
|
2023-02-07 10:20:05 -06:00
|
|
|
type AvailablePlugins map[plugins.Type]map[string]*availablePluginDTO
|
2021-11-01 04:53:33 -05:00
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
func (ap AvailablePlugins) Get(pluginType plugins.Type, pluginID string) (*availablePluginDTO, bool) {
|
2023-06-02 12:46:12 -05:00
|
|
|
p, exists := ap[pluginType][pluginID]
|
|
|
|
if exists {
|
|
|
|
return p, true
|
|
|
|
}
|
|
|
|
for _, p = range ap[pluginType] {
|
2023-09-29 10:20:37 -05:00
|
|
|
if p.Plugin.ID == pluginID || slices.Contains(p.Plugin.AliasIDs, pluginID) {
|
2023-06-02 12:46:12 -05:00
|
|
|
return p, true
|
|
|
|
}
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
2023-02-07 10:20:05 -06:00
|
|
|
return nil, false
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
func (hs *HTTPServer) availablePlugins(ctx context.Context, orgID int64) (AvailablePlugins, error) {
|
|
|
|
ap := make(AvailablePlugins)
|
2021-11-01 04:53:33 -05:00
|
|
|
|
2021-11-02 07:42:55 -05:00
|
|
|
pluginSettingMap, err := hs.pluginSettings(ctx, orgID)
|
2021-11-01 04:53:33 -05:00
|
|
|
if err != nil {
|
2023-02-07 10:20:05 -06:00
|
|
|
return ap, err
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
apps := make(map[string]*availablePluginDTO)
|
2023-06-08 05:21:19 -05:00
|
|
|
for _, app := range hs.pluginStore.Plugins(ctx, plugins.TypeApp) {
|
2023-02-07 10:20:05 -06:00
|
|
|
if s, exists := pluginSettingMap[app.ID]; exists {
|
|
|
|
app.Pinned = s.Pinned
|
|
|
|
apps[app.ID] = &availablePluginDTO{
|
|
|
|
Plugin: app,
|
|
|
|
Settings: *s,
|
|
|
|
}
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
}
|
2023-06-08 05:21:19 -05:00
|
|
|
ap[plugins.TypeApp] = apps
|
2021-11-01 04:53:33 -05:00
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
dataSources := make(map[string]*availablePluginDTO)
|
2023-06-08 05:21:19 -05:00
|
|
|
for _, ds := range hs.pluginStore.Plugins(ctx, plugins.TypeDataSource) {
|
2023-02-07 10:20:05 -06:00
|
|
|
if s, exists := pluginSettingMap[ds.ID]; exists {
|
|
|
|
dataSources[ds.ID] = &availablePluginDTO{
|
|
|
|
Plugin: ds,
|
|
|
|
Settings: *s,
|
|
|
|
}
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
}
|
2023-06-08 05:21:19 -05:00
|
|
|
ap[plugins.TypeDataSource] = dataSources
|
2021-11-01 04:53:33 -05:00
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
panels := make(map[string]*availablePluginDTO)
|
2023-06-08 05:21:19 -05:00
|
|
|
for _, p := range hs.pluginStore.Plugins(ctx, plugins.TypePanel) {
|
2023-02-07 10:20:05 -06:00
|
|
|
if s, exists := pluginSettingMap[p.ID]; exists {
|
|
|
|
panels[p.ID] = &availablePluginDTO{
|
|
|
|
Plugin: p,
|
|
|
|
Settings: *s,
|
|
|
|
}
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
}
|
2023-06-08 05:21:19 -05:00
|
|
|
ap[plugins.TypePanel] = panels
|
2021-11-01 04:53:33 -05:00
|
|
|
|
2023-02-07 10:20:05 -06:00
|
|
|
return ap, nil
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:20:11 -05:00
|
|
|
func (hs *HTTPServer) pluginSettings(ctx context.Context, orgID int64) (map[string]*pluginsettings.InfoDTO, error) {
|
|
|
|
pluginSettings := make(map[string]*pluginsettings.InfoDTO)
|
2021-11-01 04:53:33 -05:00
|
|
|
|
2021-11-05 09:07:53 -05:00
|
|
|
// fill settings from database
|
2022-03-18 14:49:13 -05:00
|
|
|
if pss, err := hs.PluginSettings.GetPluginSettings(ctx, &pluginsettings.GetArgs{OrgID: orgID}); err != nil {
|
2021-11-05 09:07:53 -05:00
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
for _, ps := range pss {
|
2022-03-18 14:49:13 -05:00
|
|
|
pluginSettings[ps.PluginID] = ps
|
2021-11-05 09:07:53 -05:00
|
|
|
}
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
|
2021-11-05 09:07:53 -05:00
|
|
|
// fill settings from app plugins
|
2023-06-08 05:21:19 -05:00
|
|
|
for _, plugin := range hs.pluginStore.Plugins(ctx, plugins.TypeApp) {
|
2021-11-05 09:07:53 -05:00
|
|
|
// ignore settings that already exist
|
|
|
|
if _, exists := pluginSettings[plugin.ID]; exists {
|
2021-11-01 04:53:33 -05:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2021-11-05 09:07:53 -05:00
|
|
|
// add new setting which is enabled depending on if AutoEnabled: true
|
2022-09-21 05:20:11 -05:00
|
|
|
pluginSetting := &pluginsettings.InfoDTO{
|
|
|
|
PluginID: plugin.ID,
|
|
|
|
OrgID: orgID,
|
|
|
|
Enabled: plugin.AutoEnabled,
|
|
|
|
Pinned: plugin.AutoEnabled,
|
|
|
|
PluginVersion: plugin.Info.Version,
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
|
2021-11-05 09:07:53 -05:00
|
|
|
pluginSettings[plugin.ID] = pluginSetting
|
|
|
|
}
|
|
|
|
|
|
|
|
// fill settings from all remaining plugins (including potential app child plugins)
|
2021-11-17 05:04:22 -06:00
|
|
|
for _, plugin := range hs.pluginStore.Plugins(ctx) {
|
2021-11-05 09:07:53 -05:00
|
|
|
// ignore settings that already exist
|
|
|
|
if _, exists := pluginSettings[plugin.ID]; exists {
|
|
|
|
continue
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
|
2021-11-05 09:07:53 -05:00
|
|
|
// add new setting which is enabled by default
|
2022-09-21 05:20:11 -05:00
|
|
|
pluginSetting := &pluginsettings.InfoDTO{
|
|
|
|
PluginID: plugin.ID,
|
|
|
|
OrgID: orgID,
|
|
|
|
Enabled: true,
|
|
|
|
Pinned: false,
|
|
|
|
PluginVersion: plugin.Info.Version,
|
2021-11-05 09:07:53 -05:00
|
|
|
}
|
2021-11-01 04:53:33 -05:00
|
|
|
|
2021-11-05 09:07:53 -05:00
|
|
|
// if plugin is included in an app, check app settings
|
|
|
|
if plugin.IncludedInAppID != "" {
|
|
|
|
// app child plugins are disabled unless app is enabled
|
|
|
|
pluginSetting.Enabled = false
|
|
|
|
if p, exists := pluginSettings[plugin.IncludedInAppID]; exists {
|
|
|
|
pluginSetting.Enabled = p.Enabled
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
}
|
2021-11-05 09:07:53 -05:00
|
|
|
pluginSettings[plugin.ID] = pluginSetting
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
|
|
|
|
2021-11-05 09:07:53 -05:00
|
|
|
return pluginSettings, nil
|
2021-11-01 04:53:33 -05:00
|
|
|
}
|
2022-11-15 03:50:37 -06:00
|
|
|
|
2023-08-30 10:46:47 -05:00
|
|
|
func (hs *HTTPServer) getEnabledOAuthProviders() map[string]any {
|
|
|
|
providers := make(map[string]any)
|
2022-11-15 03:50:37 -06:00
|
|
|
for key, oauth := range hs.SocialService.GetOAuthInfoProviders() {
|
|
|
|
providers[key] = map[string]string{
|
|
|
|
"name": oauth.Name,
|
|
|
|
"icon": oauth.Icon,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return providers
|
|
|
|
}
|