mirror of
https://gitlab.com/hagrid-keyserver/hagrid.git
synced 2023-02-13 20:55:02 -05:00
Only delete (address, key) mappings.
- We still want to provide the key material for updates, or revocations. - Fixes #73.
This commit is contained in:
parent
8106d2cec6
commit
ab4f941ac2
2 changed files with 8 additions and 36 deletions
|
@ -505,13 +505,12 @@ pub trait Database: Sync + Send {
|
|||
}
|
||||
}
|
||||
|
||||
// if fpr = pop-token(tok) {
|
||||
// tpk = by_fpr(fpr)
|
||||
// for uid in tpk.userids {
|
||||
// del-uid(uid)
|
||||
// }
|
||||
// del-fpr(fpr)
|
||||
// }
|
||||
/// Deletes (address, key)-mappings.
|
||||
///
|
||||
/// Given a valid deletion token, this function unlinks all email
|
||||
/// addresses and strips all UserIDs from the stored TPK.
|
||||
///
|
||||
/// Returns true if the token was valid.
|
||||
fn confirm_deletion(&self, token: &str) -> Result<bool> {
|
||||
let _ = self.lock();
|
||||
|
||||
|
@ -522,33 +521,8 @@ pub trait Database: Sync + Send {
|
|||
return Ok(false);
|
||||
}
|
||||
|
||||
loop {
|
||||
match self.by_fpr(&fpr) {
|
||||
Some(old) => {
|
||||
let tpk = match TPK::from_bytes(old.as_bytes()) {
|
||||
Ok(tpk) => tpk,
|
||||
Err(e) => {
|
||||
return Err(failure::format_err!(
|
||||
"Failed to parse old TPK: {:?}",
|
||||
e));
|
||||
}
|
||||
};
|
||||
|
||||
for uid in tpk.userids() {
|
||||
self.unlink_email(
|
||||
&Email::try_from(uid.userid())?,
|
||||
&fpr,
|
||||
)?;
|
||||
}
|
||||
|
||||
self.update(&fpr, None)?;
|
||||
return Ok(true);
|
||||
}
|
||||
None => {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.filter_userids(&fpr, |_| false)?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
None => Ok(false),
|
||||
|
|
|
@ -418,7 +418,6 @@ pub fn test_uid_deletion_request<D: Database>(db: &mut D) {
|
|||
assert!(db.confirm_deletion(&del).unwrap());
|
||||
|
||||
// check it's gone
|
||||
assert!(db.by_fpr(&fpr).is_none());
|
||||
assert!(db.by_email(&email1).is_none());
|
||||
assert!(db.by_email(&email2).is_none());
|
||||
|
||||
|
@ -426,7 +425,6 @@ pub fn test_uid_deletion_request<D: Database>(db: &mut D) {
|
|||
assert!(!db.confirm_deletion(&del).unwrap());
|
||||
|
||||
// check it's still gone
|
||||
assert!(db.by_fpr(&fpr).is_none());
|
||||
assert!(db.by_email(&email1).is_none());
|
||||
assert!(db.by_email(&email2).is_none());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue