diff options
author | 6543 <24977596+6543@users.noreply.github.com> | 2019-11-29 06:28:38 +0100 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-11-29 00:28:38 -0500 |
commit | f36efe0b548959c29253cfe8b3a2d0c610cc0869 (patch) | |
tree | 1b8568156636b058d3eb89300a40a77ea6dfe57d | |
parent | 38664d7f3947076a3ce48eb01276fc097bf842d2 (diff) | |
download | gitea-f36efe0b548959c29253cfe8b3a2d0c610cc0869.tar.gz gitea-f36efe0b548959c29253cfe8b3a2d0c610cc0869.zip |
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
-rw-r--r-- | routers/admin/admin.go | 14 | ||||
-rw-r--r-- | templates/admin/config.tmpl | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 4c4738ae8c..45bdbfe7f2 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -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 } @@ -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 to unmarshall session config for virtualed provider config: %s\nError: %v", sessionCfg.ProviderConfig, err) + } + sessionCfg = realSession + } sessionCfg.ProviderConfig = shadowPassword(sessionCfg.Provider, sessionCfg.ProviderConfig) - ctx.Data["SessionConfig"] = sessionCfg ctx.Data["DisableGravatar"] = setting.DisableGravatar diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index 79eec31dfd..c2793ece9d 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -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> |