Skip to content

Commit 54dab5a

Browse files
zeripathtechknowlogick
authored andcommitted
Properly fix displaying virtual session provider in admin panel (#9137)
* Properly fix #7127 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 #7127 * update per @silverwind's suggestion
1 parent 3bdce82 commit 54dab5a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

routers/admin/admin.go

Lines changed: 7 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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)