summaryrefslogtreecommitdiffstats
path: root/models/migrations/v1_19
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2022-12-20 17:07:13 +0800
committerGitHub <noreply@github.com>2022-12-20 17:07:13 +0800
commit659055138b6d32492b20c9f4d1d5a3cdaa47188d (patch)
treee2e7741be2b7b349e04f6901bff92b75b9b7c9ac /models/migrations/v1_19
parent40ba750c4bf1f3f5f8dff5af57b2db4b600f237f (diff)
downloadgitea-659055138b6d32492b20c9f4d1d5a3cdaa47188d.tar.gz
gitea-659055138b6d32492b20c9f4d1d5a3cdaa47188d.zip
Secrets storage with SecretKey encrypted (#22142)
Fork of #14483, but [gave up MasterKey](https://github.com/go-gitea/gitea/pull/14483#issuecomment-1350728557), and fixed some problems. Close #12065. Needed by #13539. Featrues: - Secrets for repo and org, not user yet. - Use SecretKey to encrypte/encrypt secrets. - Trim spaces of secret value. - Add a new locale ini block, to make it easy to support secrets for user. Snapshots: Repo level secrets: ![image](https://user-images.githubusercontent.com/9418365/207823319-b8a4903f-38ca-4af7-9d05-336a5af906f3.png) Rrg level secrets ![image](https://user-images.githubusercontent.com/9418365/207823371-8bd02e93-1928-40d1-8c76-f48b255ace36.png) Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'models/migrations/v1_19')
-rw-r--r--models/migrations/v1_19/v236.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/models/migrations/v1_19/v236.go b/models/migrations/v1_19/v236.go
new file mode 100644
index 0000000000..f172a85b1f
--- /dev/null
+++ b/models/migrations/v1_19/v236.go
@@ -0,0 +1,23 @@
+// Copyright 2022 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+package v1_19 //nolint
+
+import (
+ "code.gitea.io/gitea/modules/timeutil"
+
+ "xorm.io/xorm"
+)
+
+func CreateSecretsTable(x *xorm.Engine) error {
+ type Secret struct {
+ ID int64
+ OwnerID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL"`
+ RepoID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL DEFAULT 0"`
+ Name string `xorm:"UNIQUE(owner_repo_name) NOT NULL"`
+ Data string `xorm:"LONGTEXT"`
+ CreatedUnix timeutil.TimeStamp `xorm:"created NOT NULL"`
+ }
+
+ return x.Sync(new(Secret))
+}