diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-03-22 17:29:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 17:29:07 +0800 |
commit | 2b55422cd71b0b325f054646de5cebf39b72b502 (patch) | |
tree | 27e71f4e6e27fd5bbb2c13a27e572ef0b41a1e6d /cmd | |
parent | 80fd25524e13dedbdc3527b32d008de152213a89 (diff) | |
download | gitea-2b55422cd71b0b325f054646de5cebf39b72b502.tar.gz gitea-2b55422cd71b0b325f054646de5cebf39b72b502.zip |
Fix the bug: deploy key with write access can not push (#19010)
Use DeployKeyID to replace the IsDeployKey, then CanWriteCode uses the DeployKeyID to check the write permission.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/hook.go | 4 | ||||
-rw-r--r-- | cmd/serv.go | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/cmd/hook.go b/cmd/hook.go index 1dd59e8192..05fa6e56c1 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -185,7 +185,7 @@ Gitea or set your environment appropriately.`, "") reponame := os.Getenv(models.EnvRepoName) userID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64) prID, _ := strconv.ParseInt(os.Getenv(models.EnvPRID), 10, 64) - isDeployKey, _ := strconv.ParseBool(os.Getenv(models.EnvIsDeployKey)) + deployKeyID, _ := strconv.ParseInt(os.Getenv(models.EnvDeployKeyID), 10, 64) hookOptions := private.HookOptions{ UserID: userID, @@ -194,7 +194,7 @@ Gitea or set your environment appropriately.`, "") GitQuarantinePath: os.Getenv(private.GitQuarantinePath), GitPushOptions: pushOptions(), PullRequestID: prID, - IsDeployKey: isDeployKey, + DeployKeyID: deployKeyID, } scanner := bufio.NewScanner(os.Stdin) diff --git a/cmd/serv.go b/cmd/serv.go index b4ef37f1dc..c834ca298a 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -243,7 +243,7 @@ func runServ(c *cli.Context) error { os.Setenv(models.EnvPusherID, strconv.FormatInt(results.UserID, 10)) os.Setenv(models.EnvRepoID, strconv.FormatInt(results.RepoID, 10)) os.Setenv(models.EnvPRID, fmt.Sprintf("%d", 0)) - os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey)) + os.Setenv(models.EnvDeployKeyID, fmt.Sprintf("%d", results.DeployKeyID)) os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID)) os.Setenv(models.EnvAppURL, setting.AppURL) |