Auth: add name parameter to auth.saml (#39883)

* add name parameter to auth.saml

* Create constant to store default SAML name
This commit is contained in:
Guilherme Caulada 2021-10-04 09:58:16 -03:00 committed by GitHub
parent 5219c72a6c
commit 706a665240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 2 deletions

View File

@ -1,2 +1,3 @@
export const GAUGE_DEFAULT_MINIMUM = 0;
export const GAUGE_DEFAULT_MAXIMUM = 100;
export const DEFAULT_SAML_NAME = 'SAML';

View File

@ -44,6 +44,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
ldapEnabled = false;
sigV4AuthEnabled = false;
samlEnabled = false;
samlName = '';
autoAssignOrg = true;
verifyEmailEnabled = false;
oauth: any;

View File

@ -97,6 +97,7 @@ func (hs *HTTPServer) LoginView(c *models.ReqContext) {
viewData.Settings["oauth"] = enabledOAuths
viewData.Settings["samlEnabled"] = hs.samlEnabled()
viewData.Settings["samlName"] = hs.samlName()
if loginError, ok := hs.tryGetEncryptedCookie(c, loginErrorCookieName); ok {
// this cookie is only set whenever an OAuth login fails
@ -346,6 +347,10 @@ func (hs *HTTPServer) samlEnabled() bool {
return hs.SettingsProvider.KeyValue("auth.saml", "enabled").MustBool(false) && hs.License.HasValidLicense()
}
func (hs *HTTPServer) samlName() string {
return hs.SettingsProvider.KeyValue("auth.saml", "name").MustString("SAML")
}
func (hs *HTTPServer) samlSingleLogoutEnabled() bool {
return hs.SettingsProvider.KeyValue("auth.saml", "single_logout").MustBool(false) && hs.samlEnabled()
}

View File

@ -2,7 +2,7 @@ import React from 'react';
import config from 'app/core/config';
import { css, cx } from '@emotion/css';
import { Icon, IconName, LinkButton, useStyles, useTheme2, VerticalGroup } from '@grafana/ui';
import { GrafanaTheme, GrafanaTheme2 } from '@grafana/data';
import { GrafanaTheme, GrafanaTheme2, DEFAULT_SAML_NAME } from '@grafana/data';
import { pickBy } from 'lodash';
export interface LoginService {
@ -24,7 +24,7 @@ const loginServices: () => LoginServices = () => {
saml: {
bgColor: '#464646',
enabled: config.samlEnabled,
name: 'SAML',
name: config.samlName || DEFAULT_SAML_NAME,
icon: 'key-skeleton-alt',
},
google: {