gitea源码

key.go 969B

123456789101112131415161718192021222324252627
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package git
  4. import "code.gitea.io/gitea/modules/setting"
  5. // Based on https://git-scm.com/docs/git-config#Documentation/git-config.txt-gpgformat
  6. const (
  7. SigningKeyFormatOpenPGP = "openpgp" // for GPG keys, the expected default of git cli
  8. SigningKeyFormatSSH = "ssh"
  9. )
  10. // SigningKey represents an instance key info which will be used to sign git commits.
  11. // FIXME: need to refactor it to a new name, this name conflicts with the variable names for "asymkey.GPGKey" in many places.
  12. type SigningKey struct {
  13. KeyID string
  14. Format string
  15. }
  16. func (s *SigningKey) String() string {
  17. // Do not expose KeyID
  18. // In case the key is a file path and the struct is rendered in a template, then the server path will be exposed.
  19. setting.PanicInDevOrTesting("don't call SigningKey.String() - it exposes the KeyID which might be a local file path")
  20. return "SigningKey:" + s.Format
  21. }