Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

signing.en-us.md 5.0KB

Sign merges, CRUD, Wiki and Repository initialisation with gpg key (#7631) This PR fixes #7598 by providing a configurable way of signing commits across the Gitea instance. Per repository configurability and import/generation of trusted secure keys is not provided by this PR - from a security PoV that's probably impossible to do properly. Similarly web-signing, that is asking the user to sign something, is not implemented - this could be done at a later stage however. ## Features - [x] If commit.gpgsign is set in .gitconfig sign commits and files created through repofiles. (merges should already have been signed.) - [x] Verify commits signed with the default gpg as valid - [x] Signer, Committer and Author can all be different - [x] Allow signer to be arbitrarily different - We still require the key to have an activated email on Gitea. A more complete implementation would be to use a keyserver and mark external-or-unactivated with an "unknown" trust level icon. - [x] Add a signing-key.gpg endpoint to get the default gpg pub key if available - Rather than add a fake web-flow user I've added this as an endpoint on /api/v1/signing-key.gpg - [x] Try to match the default key with a user on gitea - this is done at verification time - [x] Make things configurable? - app.ini configuration done - [x] when checking commits are signed need to check if they're actually verifiable too - [x] Add documentation I have decided that adjusting the docker to create a default gpg key is not the correct thing to do and therefore have not implemented this.
4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. ---
  2. date: "2019-08-17T10:20:00+01:00"
  3. title: "GPG Commit Signatures"
  4. slug: "signing"
  5. weight: 20
  6. toc: false
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "advanced"
  11. name: "GPG Commit Signatures"
  12. weight: 20
  13. identifier: "signing"
  14. ---
  15. # GPG Commit Signatures
  16. Gitea will verify GPG commit signatures in the provided tree by
  17. checking if the commits are signed by a key within the gitea database,
  18. or if the commit matches the default key for git.
  19. Keys are not checked to determine if they have expired or revoked.
  20. Keys are also not checked with keyservers.
  21. A commit will be marked with a grey unlocked icon if no key can be
  22. found to verify it. If a commit is marked with a red unlocked icon,
  23. it is reported to be signed with a key with an id.
  24. Please note: The signer of a commit does not have to be an author or
  25. committer of a commit.
  26. This functionality requires git >= 1.7.9 but for full functionality
  27. this requires git >= 2.0.0.
  28. ## Automatic Signing
  29. There are a number of places where Gitea will generate commits itself:
  30. * Repository Initialisation
  31. * Wiki Changes
  32. * CRUD actions using the editor or the API
  33. * Merges from Pull Requests
  34. Depending on configuration and server trust you may want Gitea to
  35. sign these commits.
  36. ## General Configuration
  37. Gitea's configuration for signing can be found with the
  38. `[repository.signing]` section of `app.ini`:
  39. ```ini
  40. ...
  41. [repository.signing]
  42. SIGNING_KEY = default
  43. SIGNING_NAME =
  44. SIGNING_EMAIL =
  45. INITIAL_COMMIT = always
  46. CRUD_ACTIONS = pubkey, twofa, parentsigned
  47. WIKI = never
  48. MERGES = pubkey, twofa, basesigned, commitssigned
  49. ...
  50. ```
  51. ### `SIGNING_KEY`
  52. The first option to discuss is the `SIGNING_KEY`. There are three main
  53. options:
  54. * `none` - this prevents Gitea from signing any commits
  55. * `default` - Gitea will default to the key configured within
  56. `git config`
  57. * `KEYID` - Gitea will sign commits with the gpg key with the ID
  58. `KEYID`. In this case you should provide a `SIGNING_NAME` and
  59. `SIGNING_EMAIL` to be displayed for this key.
  60. The `default` option will interrogate `git config` for
  61. `commit.gpgsign` option - if this is set, then it will use the results
  62. of the `user.signingkey`, `user.name` and `user.email` as appropriate.
  63. Please note: by adjusting git's `config` file within Gitea's
  64. repositories, `SIGNING_KEY=default` could be used to provide different
  65. signing keys on a per-repository basis. However, this is cleary not an
  66. ideal UI and therefore subject to change.
  67. ### `INITIAL_COMMIT`
  68. This option determines whether Gitea should sign the initial commit
  69. when creating a repository. The possible values are:
  70. * `never`: Never sign
  71. * `pubkey`: Only sign if the user has a public key
  72. * `twofa`: Only sign if the user logs in with two factor authentication
  73. * `always`: Always sign
  74. Options other than `never` and `always` can be combined as a comma
  75. separated list.
  76. ### `WIKI`
  77. This options determines if Gitea should sign commits to the Wiki.
  78. The possible values are:
  79. * `never`: Never sign
  80. * `pubkey`: Only sign if the user has a public key
  81. * `twofa`: Only sign if the user logs in with two factor authentication
  82. * `parentsigned`: Only sign if the parent commit is signed.
  83. * `always`: Always sign
  84. Options other than `never` and `always` can be combined as a comma
  85. separated list.
  86. ### `CRUD_ACTIONS`
  87. This option determines if Gitea should sign commits from the web
  88. editor or API CRUD actions. The possible values are:
  89. * `never`: Never sign
  90. * `pubkey`: Only sign if the user has a public key
  91. * `twofa`: Only sign if the user logs in with two factor authentication
  92. * `parentsigned`: Only sign if the parent commit is signed.
  93. * `always`: Always sign
  94. Options other than `never` and `always` can be combined as a comma
  95. separated list.
  96. ### `MERGES`
  97. This option determines if Gitea should sign merge commits from PRs.
  98. The possible options are:
  99. * `never`: Never sign
  100. * `pubkey`: Only sign if the user has a public key
  101. * `twofa`: Only sign if the user logs in with two factor authentication
  102. * `basesigned`: Only sign if the parent commit in the base repo is signed.
  103. * `headsigned`: Only sign if the head commit in the head branch is signed.
  104. * `commitssigned`: Only sign if all the commits in the head branch to the merge point are signed.
  105. * `always`: Always sign
  106. Options other than `never` and `always` can be combined as a comma
  107. separated list.
  108. ## Installing and generating a GPG key for Gitea
  109. It is up to a server administrator to determine how best to install
  110. a signing key. Gitea generates all its commits using the server `git`
  111. command at present - and therefore the server `gpg` will be used for
  112. signing (if configured.) Administrators should review best-practices
  113. for gpg - in particular it is probably advisable to only install a
  114. signing secret subkey without the master signing and certifying secret
  115. key.
  116. ## Obtaining the Public Key of the Signing Key
  117. The public key used to sign Gitea's commits can be obtained from the API at:
  118. ```/api/v1/signing-key.gpg```
  119. In cases where there is a repository specific key this can be obtained from:
  120. ```/api/v1/repos/:username/:reponame/signing-key.gpg```