Revert "Add simple master key provider for secret encryption"

This reverts commit d4e84c0433.
This commit is contained in:
Jason Song
2022-12-22 11:45:06 +08:00
parent b54f148164
commit 88e813d1ca
12 changed files with 0 additions and 305 deletions

View File

@ -66,8 +66,3 @@ func NewSecretKey() (string, error) {
return secretKey, nil
}
// NewMasterKey generate a new value intended to be used by MASTER_KEY.
func NewMasterKey() ([]byte, error) {
return util.CryptoRandomBytes(32)
}

View File

@ -216,8 +216,6 @@ var (
HMACKey string `ini:"HMAC_KEY"`
Allways bool
}{}
MasterKeyProvider string
MasterKey []byte
// UI settings
UI = struct {
@ -977,19 +975,6 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
PasswordCheckPwn = sec.Key("PASSWORD_CHECK_PWN").MustBool(false)
SuccessfulTokensCacheSize = sec.Key("SUCCESSFUL_TOKENS_CACHE_SIZE").MustInt(20)
// Master key provider configuration
MasterKeyProvider = sec.Key("MASTER_KEY_PROVIDER").MustString("plain")
switch MasterKeyProvider {
case "plain":
tempSalt := []byte{'g', 'i', 't', 'e', 'a'}
MasterKey = []byte(sec.Key("MASTER_KEY").MustString(SecretKey))
MasterKey = pbkdf2.Key(MasterKey, tempSalt, 4096, 32, sha1.New)
case "none":
default:
log.Fatal("invalid master key provider type: %v", MasterKeyProvider)
return
}
InternalToken = loadSecret(sec, "INTERNAL_TOKEN_URI", "INTERNAL_TOKEN")
if InstallLock && InternalToken == "" {
// if Gitea has been installed but the InternalToken hasn't been generated (upgrade from an old release), we should generate

View File

@ -78,11 +78,6 @@ func GetInclude(field reflect.StructField) string {
return getRuleBody(field, "Include(")
}
// GetIn get allowed values in form tag
func GetIn(field reflect.StructField) string {
return getRuleBody(field, "In(")
}
// Validate validate TODO:
func Validate(errs binding.Errors, data map[string]interface{}, f Form, l translation.Locale) binding.Errors {
if errs.Len() == 0 {
@ -135,8 +130,6 @@ func Validate(errs binding.Errors, data map[string]interface{}, f Form, l transl
data["ErrorMsg"] = trName + l.Tr("form.url_error", errs[0].Message)
case binding.ERR_INCLUDE:
data["ErrorMsg"] = trName + l.Tr("form.include_error", GetInclude(field))
case binding.ERR_IN:
data["ErrorMsg"] = trName + l.Tr("form.in_error", strings.Join(strings.Split(GetIn(field), ","), ", "))
case validation.ErrGlobPattern:
data["ErrorMsg"] = trName + l.Tr("form.glob_pattern_error", errs[0].Message)
case validation.ErrRegexPattern: