-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[#5356] Delete GPG keys with user deletion #5357
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,6 +239,16 @@ func parseGPGKey(ownerID int64, e *openpgp.Entity) (*GPGKey, error) { | |
}, nil | ||
} | ||
|
||
// deleteGPGKeys does the actual key deletion but does not update authorized_keys file. | ||
func deleteGPGKeys(e *xorm.Session, keyIDs ...int64) error { | ||
if len(keyIDs) == 0 { | ||
return nil | ||
} | ||
|
||
_, err := e.In("id", keyIDs).Delete(new(GPGKey)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a nice solution and makes this code a lot smaller. Also this check can simplify the public key deletion. |
||
return err | ||
} | ||
|
||
// deleteGPGKey does the actual key deletion | ||
func deleteGPGKey(e *xorm.Session, keyID string) (int64, error) { | ||
if keyID == "" { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
Can you add for information that this method will not delete any related (subkey) compared to deleteGPGKey ? And you should loose the authorized_keys file part since it not related to GPG.
Something like :
or add :
_, err := e.In("primary_key_id", keyIDs).Delete(new(GPGKey))
each solution is fine as the list passed should already contained any related keys in the original use case.
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.
But deleteGPGKeys does also delete all subkeys of a master key which are assigned to a user. More specifically: deleteGPGKeys deletes all keys of a specified user.
Uh oh!
There was an error while loading. Please reload this page.
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.
This is just in case for later use in other part in code. Currently when you call this method here you pass all keys (and subkeys) owned by user. But if this method is used somewhere else there could be orphaned subkeys if not all the key are passed as argument. This is just to add a warning for later use (or add the delete of any sub key).