Skip to content
Merged
Changes from 1 commit
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
19 changes: 17 additions & 2 deletions routers/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ func SendTestMail(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/admin/config")
}

func shadowPassword(cfgItem string) string {
fields := strings.Split(cfgItem, ",")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there need to be more than one check, since the config strings can be different for MySQL and redis. This seems to fix for redis, but not MySQL. In the example from #7147, the session provider connection string is:

someclient:somepassword@tcp(srv-mysql:3306)/someclient

This format uses DSN, so the password is optional: https://github.com/go-sql-driver/mysql

Maybe it you can also pass in the adapter/provider to shadowPassword and then know if it is Redis/MySQL and check based on that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Will fix that.

for i := 0; i < len(fields); i++ {
if strings.HasPrefix(fields[i], "password=") {
fields[i] = "password=******"
break
}
}
return strings.Join(fields, ",")
}

// Config show admin config page
func Config(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("admin.config")
Expand Down Expand Up @@ -239,10 +250,14 @@ func Config(ctx *context.Context) {

ctx.Data["CacheAdapter"] = setting.CacheService.Adapter
ctx.Data["CacheInterval"] = setting.CacheService.Interval
ctx.Data["CacheConn"] = setting.CacheService.Conn

ctx.Data["CacheConn"] = shadowPassword(setting.CacheService.Conn)
ctx.Data["CacheItemTTL"] = setting.CacheService.TTL

ctx.Data["SessionConfig"] = setting.SessionConfig
sessionCfg := setting.SessionConfig
sessionCfg.ProviderConfig = shadowPassword(sessionCfg.ProviderConfig)

ctx.Data["SessionConfig"] = sessionCfg

ctx.Data["DisableGravatar"] = setting.DisableGravatar
ctx.Data["EnableFederatedAvatar"] = setting.EnableFederatedAvatar
Expand Down