From b3aaf544a6f27fc1d152d67600d110b3c26460c8 Mon Sep 17 00:00:00 2001 From: Misi Date: Tue, 25 Apr 2023 13:13:55 +0200 Subject: [PATCH] Auth: Add authentication config frontend routes to api.go (#66931) * Add auth config frontend routes to api.go * Remove SAML related endpoints * Fix routes * Enable authconfig for Enterprise, Cloud Pro and Advanced * Fix * Update public/app/routes/routes.tsx Co-authored-by: Alexander Zobnin --------- Co-authored-by: Alexander Zobnin --- pkg/api/api.go | 4 ++++ public/app/routes/routes.tsx | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index c19239757b6..72f86ea6a34 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -224,6 +224,10 @@ func (hs *HTTPServer) registerRoutes() { r.Get("/user/auth-tokens/rotate", routing.Wrap(hs.RotateUserAuthTokenRedirect)) } + if hs.License.FeatureEnabled("saml") && hs.Features.IsEnabled(featuremgmt.FlagAuthenticationConfigUI) { + r.Get("/admin/authentication/", authorize(reqGrafanaAdmin, ac.EvalPermission(ac.ActionSettingsRead, ac.ScopeSettingsAll)), hs.Index) + } + // authed api r.Group("/api", func(apiRoute routing.RouteRegister) { // user (signed in) diff --git a/public/app/routes/routes.tsx b/public/app/routes/routes.tsx index a41e7ee3f06..96ed930aa70 100644 --- a/public/app/routes/routes.tsx +++ b/public/app/routes/routes.tsx @@ -309,11 +309,12 @@ export function getAppRoutes(): RouteDescriptor[] { // ADMIN { path: '/admin/authentication', - component: config.featureToggles.authenticationConfigUI - ? SafeDynamicImport( - () => import(/* webpackChunkName: "AdminAuthentication" */ 'app/features/auth-config/AuthConfigPage') - ) - : () => , + component: + config.featureToggles.authenticationConfigUI && config.licenseInfo.enabledFeatures?.saml + ? SafeDynamicImport( + () => import(/* webpackChunkName: "AdminAuthentication" */ 'app/features/auth-config/AuthConfigPage') + ) + : () => , }, { path: '/admin',