From 2b55422cd71b0b325f054646de5cebf39b72b502 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 22 Mar 2022 17:29:07 +0800 Subject: 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. --- models/asymkey/ssh_key_deploy.go | 8 +------- models/helper_environment.go | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'models') diff --git a/models/asymkey/ssh_key_deploy.go b/models/asymkey/ssh_key_deploy.go index fc6324792a..fe2ade43ae 100644 --- a/models/asymkey/ssh_key_deploy.go +++ b/models/asymkey/ssh_key_deploy.go @@ -58,7 +58,7 @@ func (key *DeployKey) GetContent() error { return nil } -// IsReadOnly checks if the key can only be used for read operations +// IsReadOnly checks if the key can only be used for read operations, used by template func (key *DeployKey) IsReadOnly() bool { return key.Mode == perm.AccessModeRead } @@ -203,12 +203,6 @@ func UpdateDeployKeyCols(key *DeployKey, cols ...string) error { return err } -// UpdateDeployKey updates deploy key information. -func UpdateDeployKey(key *DeployKey) error { - _, err := db.GetEngine(db.DefaultContext).ID(key.ID).AllCols().Update(key) - return err -} - // ListDeployKeysOptions are options for ListDeployKeys type ListDeployKeysOptions struct { db.ListOptions diff --git a/models/helper_environment.go b/models/helper_environment.go index 57ec3ea1e9..4cad1e5368 100644 --- a/models/helper_environment.go +++ b/models/helper_environment.go @@ -23,8 +23,8 @@ const ( EnvPusherName = "GITEA_PUSHER_NAME" EnvPusherEmail = "GITEA_PUSHER_EMAIL" EnvPusherID = "GITEA_PUSHER_ID" - EnvKeyID = "GITEA_KEY_ID" - EnvIsDeployKey = "GITEA_IS_DEPLOY_KEY" + EnvKeyID = "GITEA_KEY_ID" // public key ID + EnvDeployKeyID = "GITEA_DEPLOY_KEY_ID" EnvPRID = "GITEA_PR_ID" EnvIsInternal = "GITEA_INTERNAL_PUSH" EnvAppURL = "GITEA_ROOT_URL" -- cgit v1.2.3