This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new 333a8e0 Use the storage interface to delete SSH keys as well as
OpenPGP keys
333a8e0 is described below
commit 333a8e006ecee5eddbd03d5cad1056698c047883
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Sep 11 14:26:25 2025 +0100
Use the storage interface to delete SSH keys as well as OpenPGP keys
---
atr/routes/keys.py | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/atr/routes/keys.py b/atr/routes/keys.py
index b6c09ae..7a0dc3b 100644
--- a/atr/routes/keys.py
+++ b/atr/routes/keys.py
@@ -202,28 +202,23 @@ async def delete(session: routes.CommitterSession) ->
response.Response:
return await session.redirect(keys, error="Missing key fingerprint for
deletion.")
# Try to delete an SSH key first
- # TODO: Use the storage interface instead
- async with db.session() as data:
- ssh_key = await data.ssh_key(fingerprint=fingerprint,
asf_uid=session.uid).get()
- if ssh_key:
- # Delete the SSH key
- await data.delete(ssh_key)
- await data.commit()
- return await session.redirect(keys, success="SSH key deleted
successfully")
-
# Otherwise, delete an OpenPGP key
+ # TODO: Unmerge this, or identify the key type
async with storage.write() as write:
- wafc = write.as_foundation_committer_outcome().result_or_none()
- if wafc is None:
- return await session.redirect(keys, error="Key not found or not
owned by you")
+ wafc = write.as_foundation_committer()
+ try:
+ await wafc.ssh.delete_key(fingerprint)
+ except storage.AccessError:
+ pass
+ else:
+ return await session.redirect(keys, success="SSH key deleted
successfully")
oc: outcome.Outcome[sql.PublicSigningKey] = await
wafc.keys.delete_key(fingerprint)
- match oc:
- case outcome.Result():
- return await session.redirect(keys, success="Key deleted
successfully")
- case outcome.Error(error):
- return await session.redirect(keys, error=f"Error deleting
key: {error}")
- return await session.redirect(keys, error="Key not found or not owned by
you")
+ match oc:
+ case outcome.Result():
+ return await session.redirect(keys, success="Key deleted
successfully")
+ case outcome.Error(error):
+ return await session.redirect(keys, error=f"Error deleting key:
{error}")
@routes.committer("/keys/details/<fingerprint>", methods=["GET", "POST"])
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]