Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly fix displaying virtual session provider in admin panel #9137

Merged
merged 5 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions routers/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,7 @@ func shadowPassword(provider, cfgItem string) string {
return shadowURL(provider, cfgItem)
// postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full
// Notice: use shadowURL
case "VirtualSession":
var realSession session.Options
if err := json.Unmarshal([]byte(cfgItem), &realSession); err == nil {
return shadowPassword(realSession.Provider, realSession.ProviderConfig)
}
}

return cfgItem
}

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

sessionCfg := setting.SessionConfig
if sessionCfg.Provider == "VirtualSession" {
var realSession session.Options
if err := json.Unmarshal([]byte(sessionCfg.ProviderConfig), &realSession); err != nil {
log.Error("Unable unmarshall session config for virtualed provider config: %s\nError: %v", sessionCfg.ProviderConfig, err)
techknowlogick marked this conversation as resolved.
Show resolved Hide resolved
}
sessionCfg = realSession
}
sessionCfg.ProviderConfig = shadowPassword(sessionCfg.Provider, sessionCfg.ProviderConfig)

ctx.Data["SessionConfig"] = sessionCfg

ctx.Data["DisableGravatar"] = setting.DisableGravatar
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/config.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
<dt>{{.i18n.Tr "admin.config.session_provider"}}</dt>
<dd>{{.SessionConfig.Provider}}</dd>
<dt>{{.i18n.Tr "admin.config.provider_config"}}</dt>
<dd><pre>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig | JsonPrettyPrint}}{{else}}-{{end}}</pre></dd>
<dd><code>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig}}{{else}}-{{end}}</code></dd>
<dt>{{.i18n.Tr "admin.config.cookie_name"}}</dt>
<dd>{{.SessionConfig.CookieName}}</dd>
<dt>{{.i18n.Tr "admin.config.gc_interval_time"}}</dt>
Expand Down