diff --git a/pkg/services/navtree/navtreeimpl/admin.go b/pkg/services/navtree/navtreeimpl/admin.go index db3b11d38d1..c20fda3a6fa 100644 --- a/pkg/services/navtree/navtreeimpl/admin.go +++ b/pkg/services/navtree/navtreeimpl/admin.go @@ -15,7 +15,7 @@ func (s *ServiceImpl) getAdminNode(c *contextmodel.ReqContext) (*navtree.NavLink hasAccess := ac.HasAccess(s.accessControl, c) hasGlobalAccess := ac.HasGlobalAccess(s.accessControl, s.accesscontrolService, c) orgsAccessEvaluator := ac.EvalPermission(ac.ActionOrgsRead) - authConfigUIAvailable := s.license.FeatureEnabled("saml") + authConfigUIAvailable := s.license.FeatureEnabled("saml") || s.cfg.LDAPAuthEnabled // FIXME: while we don't have a permissions for listing plugins the legacy check has to stay as a default if pluginaccesscontrol.ReqCanAdminPlugins(s.cfg)(c) || hasAccess(pluginaccesscontrol.AdminAccessEvaluator) { diff --git a/public/app/app.ts b/public/app/app.ts index 663f47f7f54..88f85dee5a0 100644 --- a/public/app/app.ts +++ b/public/app/app.ts @@ -68,6 +68,7 @@ import { GrafanaJavascriptAgentBackend } from './core/services/echo/backends/gra import { KeybindingSrv } from './core/services/keybindingSrv'; import { startMeasure, stopMeasure } from './core/utils/metrics'; import { initDevFeatures } from './dev'; +import { initAuthConfig } from './features/auth-config'; import { getTimeSrv } from './features/dashboard/services/TimeSrv'; import { initGrafanaLive } from './features/live'; import { PanelDataErrorView } from './features/panel/components/PanelDataErrorView'; @@ -132,6 +133,8 @@ export class GrafanaApp { setTimeZoneResolver(() => config.bootData.user.timezone); initGrafanaLive(); + initAuthConfig(); + // Expose the app-wide eventbus setAppEvents(appEvents); diff --git a/public/app/features/auth-config/index.ts b/public/app/features/auth-config/index.ts index fab10de59fc..015d65622e0 100644 --- a/public/app/features/auth-config/index.ts +++ b/public/app/features/auth-config/index.ts @@ -1,4 +1,6 @@ -import { Settings, SettingsSection } from 'app/types'; +import { contextSrv } from 'app/core/core'; +import { getBackendSrv } from 'app/core/services/backend_srv'; +import { AccessControlAction, Settings, SettingsSection } from 'app/types'; import { AuthProviderInfo, GetStatusHook, AuthProviderStatus } from './types'; @@ -27,7 +29,7 @@ export function getAuthProviderInfo(provider: string) { export function getAuthProviders(cfg: Settings): SettingsSection[] { const providers: SettingsSection[] = []; for (const [section, sectionConfig] of Object.entries(cfg)) { - const provider = registeredAuthProviders.find((provider) => `auth.${provider.id}` === section); + const provider = registeredAuthProviders.find((provider: AuthProviderInfo) => `auth.${provider.id}` === section); if (provider) { const providerData = { ...sectionConfig, @@ -47,3 +49,28 @@ export async function getAuthProviderStatus(providerId: string): Promise { + if (contextSrv.hasPermission(AccessControlAction.SettingsRead)) { + const result = await getBackendSrv().get('/api/admin/settings'); + const ldapSettings = result!['auth.ldap'] || {}; + return { + configured: ldapSettings['enabled'] === 'true', + enabled: ldapSettings['enabled'] === 'true', + hide: ldapSettings['enabled'] !== 'true', + }; + } + + return { configured: false, enabled: false }; +} diff --git a/public/app/routes/routes.tsx b/public/app/routes/routes.tsx index 549cfd8f7ee..a71547b0fb3 100644 --- a/public/app/routes/routes.tsx +++ b/public/app/routes/routes.tsx @@ -299,19 +299,20 @@ export function getAppRoutes(): RouteDescriptor[] { component: SafeDynamicImport(() => import(/* webpackChunkName: "TeamPages" */ 'app/features/teams/TeamPages')), }, // ADMIN - { - path: '/admin/authentication', - roles: () => contextSrv.evaluatePermission(() => ['Admin', 'ServerAdmin'], [AccessControlAction.SettingsWrite]), - component: config.licenseInfo.enabledFeatures?.saml - ? SafeDynamicImport( - () => import(/* webpackChunkName: "AdminAuthentication" */ 'app/features/auth-config/AuthConfigPage') - ) - : () => , - }, { path: '/admin', component: () => } />, }, + { + path: '/admin/authentication', + roles: () => contextSrv.evaluatePermission(() => ['Admin', 'ServerAdmin'], [AccessControlAction.SettingsWrite]), + component: + config.licenseInfo.enabledFeatures?.saml || config.ldapEnabled + ? SafeDynamicImport( + () => import(/* webpackChunkName: "AdminAuthentication" */ 'app/features/auth-config/AuthConfigPage') + ) + : () => , + }, { path: '/admin/access', component: () => ,