Skip to content

Commit

Permalink
Enable use of default gpg key for signing commits
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zeripath committed Aug 1, 2019
1 parent 0fabdf0 commit b205fdf
Show file tree
Hide file tree
Showing 32 changed files with 968 additions and 105 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ fmt-check:
test:
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)

.PHONY: test\#%
test\#%:
GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $* $(PACKAGES)

.PHONY: coverage
coverage:
@hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
Expand Down
24 changes: 24 additions & 0 deletions custom/conf/app.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP]
; List of reasons why a Pull Request or Issue can be locked
LOCK_REASONS=Too heated,Off-topic,Resolved,Spam

[repository.signing]
; GPG key to use to sign commits, Defaults to the default - that is the value of git config --get user.signingkey
; Switch to none to stop signing completely
SIGNING_KEY = default
; Determines when gitea should sign the initial commit when creating a repository
; Either:
; - never
; - pubkey: only sign if the user has a pubkey
; - twofa: only sign if the user has logged in with twofa
; - always
; options other than none and always can be combined as comma separated list
INITIAL_COMMIT = always
; Determines when to sign for CRUD actions
; - as above
; - parentsigned: requires that the parent commit is signed.
CRUD_ACTIONS = pubkey, twofa, parentsigned
; Determines when to sign Wiki commits
; - as above
WIKI = never
; Determines when to sign on merges
; - basesigned: require that the parent of commit on the base repo is signed.
; - commitssigned: require that all the commits in the head branch are signed.
MERGES = pubkey, twofa, basesigned, commitssigned

[cors]
; More information about CORS can be found here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_response_headers
; enable cors headers (disabled by default)
Expand Down
18 changes: 18 additions & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.

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

### Repository - Signing (`repository.signing`)

- `SIGNING_KEY`: **default**: \[none, KEYID, default \]: Key to sign with.
- `INITIAL_COMMIT`: **always**: \[never, pubkey, twofa, always\]: Sign initial commit.
- `never`: Never sign
- `pubkey`: Only sign if the user has a public key
- `twofa`: Only sign if the user is logged in with twofa
- `always`: Always sign
- Options other than `never` and `always` can be combined as acomma separated list.
- `WIKI`: **never**: \[never, pubkey, twofa, always, parentsigned\]: Sign commits to wiki.
- `CRUD_ACTIONS`: **pubkey, twofa, parentsigned**: \[never, pubkey, twofa, parentsigned, always\]: Sign CRUD actions.
- Options as above, with the addition of:
- `parentsigned`: Only sign if the parent commit is signed.
- `MERGES`: **pubkey, twofa, basesigned, commitssigned**: \[never, pubkey, twofa, basesigned, commitssigned, always\]: Sign merges.
- `basesigned`: Only sign if the parent commit in the base repo is signed.
- `headsigned`: Only sign if the head commit in the head branch is signed.
- `commitssigned`: Only sign if all the commits in the head branch to the merge point are signed.

## CORS (`cors`)

- `ENABLED`: **false**: enable cors headers (disabled by default)
Expand Down
3 changes: 3 additions & 0 deletions integrations/mssql.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ ROOT = integrations/gitea-integration-mssql/gitea-repositories
LOCAL_COPY_PATH = tmp/local-repo-mssql
LOCAL_WIKI_PATH = tmp/local-wiki-mssql

[repository.signing]
SIGNING_KEY = none

[server]
SSH_DOMAIN = localhost
HTTP_PORT = 3003
Expand Down
3 changes: 3 additions & 0 deletions integrations/mysql.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ ROOT = integrations/gitea-integration-mysql/gitea-repositories
LOCAL_COPY_PATH = tmp/local-repo-mysql
LOCAL_WIKI_PATH = tmp/local-wiki-mysql

[repository.signing]
SIGNING_KEY = none

[server]
SSH_DOMAIN = localhost
HTTP_PORT = 3001
Expand Down
3 changes: 3 additions & 0 deletions integrations/mysql8.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ ROOT = integrations/gitea-integration-mysql8/gitea-repositories
LOCAL_COPY_PATH = tmp/local-repo-mysql8
LOCAL_WIKI_PATH = tmp/local-wiki-mysql8

[repository.signing]
SIGNING_KEY = none

[server]
SSH_DOMAIN = localhost
HTTP_PORT = 3004
Expand Down
3 changes: 3 additions & 0 deletions integrations/pgsql.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ ROOT = integrations/gitea-integration-pgsql/gitea-repositories
LOCAL_COPY_PATH = tmp/local-repo-pgsql
LOCAL_WIKI_PATH = tmp/local-wiki-pgsql

[repository.signing]
SIGNING_KEY = none

[server]
SSH_DOMAIN = localhost
HTTP_PORT = 3002
Expand Down
3 changes: 3 additions & 0 deletions integrations/sqlite.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ ROOT = integrations/gitea-integration-sqlite/gitea-repositories
LOCAL_COPY_PATH = tmp/local-repo-sqlite
LOCAL_WIKI_PATH = tmp/local-wiki-sqlite

[repository.signing]
SIGNING_KEY = none

[server]
SSH_DOMAIN = localhost
HTTP_PORT = 3003
Expand Down
Loading

0 comments on commit b205fdf

Please sign in to comment.