aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/setting.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-02-03 23:56:53 +0000
committerGitHub <noreply@github.com>2019-02-03 23:56:53 +0000
commit01c10a951b9db0b9f020ef657ca71eb5e5882a84 (patch)
tree6cb29db94edda9d90e9a509028bada2a61ade928 /routers/repo/setting.go
parent634cbaad2b8d091a2a3065de81e0b2b76daa5ef7 (diff)
downloadgitea-01c10a951b9db0b9f020ef657ca71eb5e5882a84.tar.gz
gitea-01c10a951b9db0b9f020ef657ca71eb5e5882a84.zip
Fix ssh deploy and user key constraints (#1357) (#5939)
1. A key can either be an ssh user key or a deploy key. It cannot be both. 2. If a key is a user key - it can only be associated with one user. 3. If a key is a deploy key - it can be used in multiple repositories and the permissions it has on those repositories can be different. 4. If a repository is deleted, its deploy keys must be deleted too. We currently don't enforce any of this and multiple repositories access with different permissions doesn't work at all. This PR enforces the following constraints: - [x] You should not be able to add the same user key as another user - [x] You should not be able to add a ssh user key which is being used as a deploy key - [x] You should not be able to add a ssh deploy key which is being used as a user key - [x] If you add an ssh deploy key to another repository you should be able to use it in different modes without losing the ability to use it in the other mode. - [x] If you delete a repository you must delete all its deploy keys. Fix #1357
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r--routers/repo/setting.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 5e9e24f9f2..4fb74f6cfa 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -622,6 +622,9 @@ func DeployKeysPost(ctx *context.Context, form auth.AddKeyForm) {
case models.IsErrDeployKeyAlreadyExist(err):
ctx.Data["Err_Content"] = true
ctx.RenderWithErr(ctx.Tr("repo.settings.key_been_used"), tplDeployKeys, &form)
+ case models.IsErrKeyAlreadyExist(err):
+ ctx.Data["Err_Content"] = true
+ ctx.RenderWithErr(ctx.Tr("settings.ssh_key_been_used"), tplDeployKeys, &form)
case models.IsErrKeyNameAlreadyUsed(err):
ctx.Data["Err_Title"] = true
ctx.RenderWithErr(ctx.Tr("repo.settings.key_name_used"), tplDeployKeys, &form)