Skip to content

Commit f36efe0

Browse files
6543techknowlogick
authored andcommitted
Properly fix displaying virtual session provider in admin panel (#9137) (#9203)
* Properly fix #7147 Although #7300 properly shadows the password from the virtual session provider, the template displaying the provider config still presumed that the config was JSON. This PR updates the template and properly hides the Virtual Session provider. Fixes #7147 * update per @silverwind's suggestion
1 parent 38664d7 commit f36efe0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

routers/admin/admin.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,7 @@ func shadowPassword(provider, cfgItem string) string {
262262
return shadowURL(provider, cfgItem)
263263
// postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full
264264
// Notice: use shadowURL
265-
case "VirtualSession":
266-
var realSession session.Options
267-
if err := json.Unmarshal([]byte(cfgItem), &realSession); err == nil {
268-
return shadowPassword(realSession.Provider, realSession.ProviderConfig)
269-
}
270265
}
271-
272266
return cfgItem
273267
}
274268

@@ -314,8 +308,14 @@ func Config(ctx *context.Context) {
314308
ctx.Data["CacheItemTTL"] = setting.CacheService.TTL
315309

316310
sessionCfg := setting.SessionConfig
311+
if sessionCfg.Provider == "VirtualSession" {
312+
var realSession session.Options
313+
if err := json.Unmarshal([]byte(sessionCfg.ProviderConfig), &realSession); err != nil {
314+
log.Error("Unable to unmarshall session config for virtualed provider config: %s\nError: %v", sessionCfg.ProviderConfig, err)
315+
}
316+
sessionCfg = realSession
317+
}
317318
sessionCfg.ProviderConfig = shadowPassword(sessionCfg.Provider, sessionCfg.ProviderConfig)
318-
319319
ctx.Data["SessionConfig"] = sessionCfg
320320

321321
ctx.Data["DisableGravatar"] = setting.DisableGravatar

templates/admin/config.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@
270270
<dt>{{.i18n.Tr "admin.config.session_provider"}}</dt>
271271
<dd>{{.SessionConfig.Provider}}</dd>
272272
<dt>{{.i18n.Tr "admin.config.provider_config"}}</dt>
273-
<dd><pre>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig | JsonPrettyPrint}}{{else}}-{{end}}</pre></dd>
273+
<dd><code>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig}}{{else}}-{{end}}</code></dd>
274274
<dt>{{.i18n.Tr "admin.config.cookie_name"}}</dt>
275275
<dd>{{.SessionConfig.CookieName}}</dd>
276276
<dt>{{.i18n.Tr "admin.config.gc_interval_time"}}</dt>

0 commit comments

Comments
 (0)