[v9.5.x] Auth: id response header (#78879)

Auth: id response header (#77871)

* Add config options for identity id response header

* Add feature to add identity id response header to all responses

* Use util.SplitString

(cherry picked from commit 21f94c5b78)
This commit is contained in:
Karl Persson
2023-12-11 09:38:15 +01:00
committed by GitHub
parent 65320de220
commit 314117a02b
4 changed files with 77 additions and 0 deletions
+14
View File
@@ -270,6 +270,9 @@ type Cfg struct {
AdminEmail string
DisableSyncLock bool
DisableLoginForm bool
IDResponseHeaderEnabled bool
IDResponseHeaderPrefix string
IDResponseHeaderNamespaces map[string]struct{}
// AWS Plugin Auth
AWSAllowedAuthProviders []string
@@ -1491,6 +1494,17 @@ func readAuthSettings(iniFile *ini.File, cfg *Cfg) (err error) {
// Azure Auth
AzureAuthEnabled = auth.Key("azure_auth_enabled").MustBool(false)
cfg.AzureAuthEnabled = AzureAuthEnabled
// ID response header
cfg.IDResponseHeaderEnabled = auth.Key("id_response_header_enabled").MustBool(false)
cfg.IDResponseHeaderPrefix = auth.Key("id_response_header_prefix").MustString("X-Grafana-")
idHeaderNamespaces := util.SplitString(auth.Key("id_response_header_namespaces").MustString(""))
cfg.IDResponseHeaderNamespaces = make(map[string]struct{}, len(idHeaderNamespaces))
for _, namespace := range idHeaderNamespaces {
cfg.IDResponseHeaderNamespaces[namespace] = struct{}{}
}
readAuthAzureADSettings(cfg)
// Google Auth