package admin
import (
+ "encoding/json"
"fmt"
"net/url"
"os"
"code.gitea.io/gitea/services/mailer"
"gitea.com/macaron/macaron"
+ "gitea.com/macaron/session"
"github.com/unknwon/com"
)
ctx.Redirect(setting.AppSubURL + "/admin/config")
}
-func shadownPasswordKV(cfgItem, splitter string) string {
+func shadowPasswordKV(cfgItem, splitter string) string {
fields := strings.Split(cfgItem, splitter)
for i := 0; i < len(fields); i++ {
if strings.HasPrefix(fields[i], "password=") {
return strings.Join(fields, splitter)
}
-func shadownURL(provider, cfgItem string) string {
+func shadowURL(provider, cfgItem string) string {
u, err := url.Parse(cfgItem)
if err != nil {
- log.Error("shodowPassword %v failed: %v", provider, err)
+ log.Error("Shadowing Password for %v failed: %v", provider, err)
return cfgItem
}
if u.User != nil {
func shadowPassword(provider, cfgItem string) string {
switch provider {
case "redis":
- return shadownPasswordKV(cfgItem, ",")
+ return shadowPasswordKV(cfgItem, ",")
case "mysql":
//root:@tcp(localhost:3306)/macaron?charset=utf8
atIdx := strings.Index(cfgItem, "@")
case "postgres":
// user=jiahuachen dbname=macaron port=5432 sslmode=disable
if !strings.HasPrefix(cfgItem, "postgres://") {
- return shadownPasswordKV(cfgItem, " ")
+ return shadowPasswordKV(cfgItem, " ")
}
-
+ fallthrough
+ case "couchbase":
+ return shadowURL(provider, cfgItem)
// postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full
- // Notice: use shadwonURL
+ // Notice: use shadowURL
+ case "VirtualSession":
+ var realSession session.Options
+ if err := json.Unmarshal([]byte(cfgItem), &realSession); err == nil {
+ return shadowPassword(realSession.Provider, realSession.ProviderConfig)
+ }
}
- // "couchbase"
- return shadownURL(provider, cfgItem)
+ return cfgItem
}
// Config show admin config page