]> source.dussan.org Git - gitea.git/commitdiff
Properly fix displaying virtual session provider in admin panel (#9137)
authorzeripath <art27@cantab.net>
Thu, 28 Nov 2019 17:35:41 +0000 (17:35 +0000)
committertechknowlogick <techknowlogick@gitea.io>
Thu, 28 Nov 2019 17:35:41 +0000 (12:35 -0500)
* 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

routers/admin/admin.go
templates/admin/config.tmpl

index 4c4738ae8c0cec9b910638e15289edad8ac91009..45bdbfe7f2d4cfe2c7f2631524743fc6a155238b 100644 (file)
@@ -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
index 79eec31dfdd6aa0e7bb2af0ca37721ad87123d68..c2793ece9dc1211be3bdb7aa48c897bbf655522d 100644 (file)
                                <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>