Skip to content

Commit b205fdf

Browse files
committed
Enable use of default gpg key for signing commits
This PR allows the signing of commits with the default GPG key with configuration in the app.ini. There are a number of points: * Signing of commits with the default key can be configured per type. * Committer and Signer have been separated in the commit view. (There is nothing in the git spec to say they have to be the same.) * Commits signed with default gpg key will be verified. * Commits which cannot be verified by the default key or by keys in the db, but have a keyID that matches one of these will be marked as suspicious. * The default key can be found at /api/v1/signing-key.gpg
1 parent 0fabdf0 commit b205fdf

32 files changed

+968
-105
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ fmt-check:
172172
test:
173173
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
174174

175+
.PHONY: test\#%
176+
test\#%:
177+
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $* $(PACKAGES)
178+
175179
.PHONY: coverage
176180
coverage:
177181
@hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \

custom/conf/app.ini.sample

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,30 @@ WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP]
7474
; List of reasons why a Pull Request or Issue can be locked
7575
LOCK_REASONS=Too heated,Off-topic,Resolved,Spam
7676

77+
[repository.signing]
78+
; GPG key to use to sign commits, Defaults to the default - that is the value of git config --get user.signingkey
79+
; Switch to none to stop signing completely
80+
SIGNING_KEY = default
81+
; Determines when gitea should sign the initial commit when creating a repository
82+
; Either:
83+
; - never
84+
; - pubkey: only sign if the user has a pubkey
85+
; - twofa: only sign if the user has logged in with twofa
86+
; - always
87+
; options other than none and always can be combined as comma separated list
88+
INITIAL_COMMIT = always
89+
; Determines when to sign for CRUD actions
90+
; - as above
91+
; - parentsigned: requires that the parent commit is signed.
92+
CRUD_ACTIONS = pubkey, twofa, parentsigned
93+
; Determines when to sign Wiki commits
94+
; - as above
95+
WIKI = never
96+
; Determines when to sign on merges
97+
; - basesigned: require that the parent of commit on the base repo is signed.
98+
; - commitssigned: require that all the commits in the head branch are signed.
99+
MERGES = pubkey, twofa, basesigned, commitssigned
100+
77101
[cors]
78102
; More information about CORS can be found here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_response_headers
79103
; enable cors headers (disabled by default)

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
7676

7777
- `LOCK_REASONS`: **Too heated,Off-topic,Resolved,Spam**: A list of reasons why a Pull Request or Issue can be locked
7878

79+
### Repository - Signing (`repository.signing`)
80+
81+
- `SIGNING_KEY`: **default**: \[none, KEYID, default \]: Key to sign with.
82+
- `INITIAL_COMMIT`: **always**: \[never, pubkey, twofa, always\]: Sign initial commit.
83+
- `never`: Never sign
84+
- `pubkey`: Only sign if the user has a public key
85+
- `twofa`: Only sign if the user is logged in with twofa
86+
- `always`: Always sign
87+
- Options other than `never` and `always` can be combined as acomma separated list.
88+
- `WIKI`: **never**: \[never, pubkey, twofa, always, parentsigned\]: Sign commits to wiki.
89+
- `CRUD_ACTIONS`: **pubkey, twofa, parentsigned**: \[never, pubkey, twofa, parentsigned, always\]: Sign CRUD actions.
90+
- Options as above, with the addition of:
91+
- `parentsigned`: Only sign if the parent commit is signed.
92+
- `MERGES`: **pubkey, twofa, basesigned, commitssigned**: \[never, pubkey, twofa, basesigned, commitssigned, always\]: Sign merges.
93+
- `basesigned`: Only sign if the parent commit in the base repo is signed.
94+
- `headsigned`: Only sign if the head commit in the head branch is signed.
95+
- `commitssigned`: Only sign if all the commits in the head branch to the merge point are signed.
96+
7997
## CORS (`cors`)
8098

8199
- `ENABLED`: **false**: enable cors headers (disabled by default)

integrations/mssql.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ ROOT = integrations/gitea-integration-mssql/gitea-repositories
2121
LOCAL_COPY_PATH = tmp/local-repo-mssql
2222
LOCAL_WIKI_PATH = tmp/local-wiki-mssql
2323

24+
[repository.signing]
25+
SIGNING_KEY = none
26+
2427
[server]
2528
SSH_DOMAIN = localhost
2629
HTTP_PORT = 3003

integrations/mysql.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ ROOT = integrations/gitea-integration-mysql/gitea-repositories
2121
LOCAL_COPY_PATH = tmp/local-repo-mysql
2222
LOCAL_WIKI_PATH = tmp/local-wiki-mysql
2323

24+
[repository.signing]
25+
SIGNING_KEY = none
26+
2427
[server]
2528
SSH_DOMAIN = localhost
2629
HTTP_PORT = 3001

integrations/mysql8.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ ROOT = integrations/gitea-integration-mysql8/gitea-repositories
2121
LOCAL_COPY_PATH = tmp/local-repo-mysql8
2222
LOCAL_WIKI_PATH = tmp/local-wiki-mysql8
2323

24+
[repository.signing]
25+
SIGNING_KEY = none
26+
2427
[server]
2528
SSH_DOMAIN = localhost
2629
HTTP_PORT = 3004

integrations/pgsql.ini.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ ROOT = integrations/gitea-integration-pgsql/gitea-repositories
2121
LOCAL_COPY_PATH = tmp/local-repo-pgsql
2222
LOCAL_WIKI_PATH = tmp/local-wiki-pgsql
2323

24+
[repository.signing]
25+
SIGNING_KEY = none
26+
2427
[server]
2528
SSH_DOMAIN = localhost
2629
HTTP_PORT = 3002

integrations/sqlite.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ ROOT = integrations/gitea-integration-sqlite/gitea-repositories
1717
LOCAL_COPY_PATH = tmp/local-repo-sqlite
1818
LOCAL_WIKI_PATH = tmp/local-wiki-sqlite
1919

20+
[repository.signing]
21+
SIGNING_KEY = none
22+
2023
[server]
2124
SSH_DOMAIN = localhost
2225
HTTP_PORT = 3003

0 commit comments

Comments
 (0)