This commit is contained in:
Lunny Xiao
2022-11-25 17:48:46 +08:00
committed by Jason Song
parent b00cd8de90
commit b8c7ea782c
5 changed files with 36 additions and 5 deletions
+4 -4
View File
@@ -967,12 +967,12 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
SuccessfulTokensCacheSize = sec.Key("SUCCESSFUL_TOKENS_CACHE_SIZE").MustInt(20)
// Master key provider configuration
MasterKeyProvider = sec.Key("MASTER_KEY_PROVIDER").MustString("none")
MasterKeyProvider = sec.Key("MASTER_KEY_PROVIDER").MustString("plain")
switch MasterKeyProvider {
case "plain":
if MasterKey, err = base64.StdEncoding.DecodeString(sec.Key("MASTER_KEY").MustString("")); err != nil {
log.Fatal("error loading master key: %v", err)
return
MasterKey = []byte(sec.Key("MASTER_KEY").MustString(SecretKey))
if len(MasterKey) > 32 {
MasterKey = MasterKey[:32]
}
case "none":
default:
+5
View File
@@ -46,6 +46,7 @@ import (
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/gitdiff"
secret_service "code.gitea.io/gitea/services/secrets"
"github.com/editorconfig/editorconfig-core-go/v2"
)
@@ -478,6 +479,10 @@ func NewFuncMap() []template.FuncMap {
"Shadow": func(s string) string {
return "******"
},
"DecryptSecret": func(s string) string {
v, _ := secret_service.DecryptString(s)
return v
},
}}
}