Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign merges, CRUD, Wiki and Repository initialisation with gpg key #7631

Merged
merged 27 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b205fdf
Enable use of default gpg key for signing commits
zeripath Jul 26, 2019
9f8cdb5
fix more unix date uses
zeripath Aug 1, 2019
35b68ce
Merge branch 'master' into web-sign
zeripath Aug 7, 2019
e5f8508
Merge branch 'master' into web-sign
zeripath Aug 16, 2019
5e5d201
fix verification for provided key id and file response
zeripath Aug 16, 2019
c4fda14
Add some integration test for gpg signing
zeripath Aug 16, 2019
483ac21
fix issue with default reason
zeripath Aug 17, 2019
7d0ffa9
Merge branch 'master' into web-sign
zeripath Aug 17, 2019
4c8487f
update vendor
zeripath Aug 17, 2019
dae22e7
Use gpg.error.not_signed_commit instead of unsigned for unsigned commits
zeripath Aug 17, 2019
f4a07a5
Restore old signing key, name, and email at end of gpg_git_test
zeripath Aug 17, 2019
b674f17
fix repofiles_delete_test
zeripath Aug 17, 2019
52740e6
Make it possible to get per repository signing-keys
zeripath Aug 17, 2019
09d771a
Update documentation
zeripath Aug 17, 2019
cf35ac6
Merge branch 'master' into web-sign
zeripath Aug 17, 2019
a7dca0b
Merge branch 'master' into web-sign
zeripath Oct 9, 2019
5d827d5
Adjust the app.ini.sample to make SIGNING_* clearer
zeripath Oct 9, 2019
83fc620
Fix duplicate declaration of modules/settings in file_test
zeripath Oct 9, 2019
61bb5c2
Merge branch 'master' into web-sign
zeripath Oct 13, 2019
942ccbe
Ensure early git functionality
zeripath Oct 13, 2019
d245253
Add functionality note
zeripath Oct 13, 2019
a1f4a0d
Oops -m is present since 1.7.2 on commit
zeripath Oct 13, 2019
e1979a7
Merge branch 'master' into web-sign
zeripath Oct 14, 2019
b03ca96
Update docs/content/doc/advanced/signing.en-us.md
zeripath Oct 15, 2019
070a5c2
Merge branch 'master' into web-sign
zeripath Oct 15, 2019
7a01822
Add swagger definitions
zeripath Oct 15, 2019
f9f14c0
Merge branch 'master' into web-sign
lafriks Oct 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make it possible to get per repository signing-keys
  • Loading branch information
zeripath committed Aug 17, 2019
commit 52740e60556f4834a0ed6e11a45c6253d7aa3a06
18 changes: 18 additions & 0 deletions models/repo_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"strings"

"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
)

Expand Down Expand Up @@ -73,6 +75,22 @@ func signingKey(repoPath string) string {
return setting.Repository.Signing.SigningKey
}

// PublicSigningKey gets the public signing key within a provided repository directory
func PublicSigningKey(repoPath string) (string, error) {
signingKey := signingKey(repoPath)
if signingKey == "" {
return "", nil
}

content, stderr, err := process.GetManager().ExecDir(-1, repoPath,
"gpg --export -a", "gpg", "--export", "-a", signingKey)
if err != nil {
log.Error("Unable to get default signing key in %s: %s, %s, %v", repoPath, signingKey, stderr, err)
return "", err
}
return content, nil
}

// SignInitialCommit determines if we should sign the initial commit to this repository
func SignInitialCommit(repoPath string, u *User) (bool, string) {
rules := signingModeFromStrings(setting.Repository.Signing.InitialCommit)
Expand Down
1 change: 1 addition & 0 deletions routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Delete("", bind(api.DeleteFileOptions{}), repo.DeleteFile)
}, reqRepoWriter(models.UnitTypeCode), reqToken())
}, reqRepoReader(models.UnitTypeCode))
m.Get("/signing-key.gpg", misc.SigningKey)
}, repoAssignment())
})

Expand Down
20 changes: 5 additions & 15 deletions routers/api/v1/misc/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,21 @@ package misc
import (
"fmt"
"net/http"
"strings"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
)

// SigningKey returns the public key of the default signing key if it exists
func SigningKey(ctx *context.Context) {
signingKey, _ := git.NewCommand("config", "--get", "user.signingkey").Run()
signingKey = strings.TrimSpace(signingKey)
if len(signingKey) == 0 {
_, err := ctx.Write([]byte{})
if err != nil {
log.Error("Error Writing empty string %v", err)
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("%v", err))
}
return
path := ""
if ctx.Repo != nil && ctx.Repo.Repository != nil {
path = ctx.Repo.Repository.RepoPath()
}

content, stderr, err := process.GetManager().Exec(
"gpg --export -a", "gpg", "--export", "-a", signingKey)
content, err := models.PublicSigningKey(path)
if err != nil {
log.Error("Unable to get default signing key: %s, %s, %v", signingKey, stderr, err)
ctx.ServerError("gpg export", err)
return
}
Expand Down