-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix ssh deploy and user key constraints (#1357) #5939
Fix ssh deploy and user key constraints (#1357) #5939
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5939 +/- ##
==========================================
+ Coverage 38.54% 38.68% +0.14%
==========================================
Files 330 330
Lines 48526 48573 +47
==========================================
+ Hits 18703 18792 +89
+ Misses 27115 27061 -54
- Partials 2708 2720 +12
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! One nit, but I'm ok if this PR remains same.
cmd/serv.go
Outdated
fail("Key access denied", "Deploy key access denied: [key_id: %d, repo_id: %d]", key.ID, repo.ID) | ||
} | ||
|
||
if deployKey.Mode < requestedMode { | ||
fail("Key permission denied", "Cannot push with deployment key: %d to repo_id: %d", key.ID, repo.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One tiny nit: I know this was the error message before your change, but could you update it to include something about this specific deploy key being read-only?
The deploykey should be deleted from public_key table if last repo which use it is deleted? |
Hi @lunny the call to deleteDeployKey manages the deletion of the PublicKey entry as necessary. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
01a9fad
to
d2e9331
Compare
OK I've added some tests and changed the failure message as per @techknowlogick If you look at the tests - I've created them in a more declarative style similar to that of TestGit. |
please backport to release/v1.7 |
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 go-gitea#1357
Backport of #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
My understanding is that the intention is:
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:
Fix #1357