finish manage ui for ssh keys

This commit is contained in:
2024-07-02 09:57:02 -04:00
parent a3a11897c2
commit 6711ce2c43
11 changed files with 336 additions and 224 deletions

View File

@ -21,6 +21,7 @@ use super::{
Credential,
Crypto,
PersistentCredential,
SshKey,
};
@ -48,6 +49,7 @@ impl CredentialRecord {
pub async fn save(&self, crypto: &Crypto, pool: &SqlitePool) -> Result<(), SaveCredentialsError> {
let type_name = match &self.credential {
Credential::AwsBase(_) => AwsBaseCredential::type_name(),
Credential::Ssh(_) => SshKey::type_name(),
_ => return Err(SaveCredentialsError::NotPersistent),
};
@ -82,6 +84,7 @@ impl CredentialRecord {
// save credential details to child table
match &self.credential {
Credential::AwsBase(b) => b.save_details(&self.id, crypto, &mut txn).await,
Credential::Ssh(s) => s.save_details(&self.id, crypto, &mut txn).await,
_ => Err(SaveCredentialsError::NotPersistent),
}?;
@ -147,6 +150,11 @@ impl CredentialRecord {
.ok_or(LoadCredentialsError::InvalidData)?;
records.push(Self::from_parts(parent, credential));
}
for (id, credential) in SshKey::list(crypto, pool).await? {
let parent = parent_map.remove(&id)
.ok_or(LoadCredentialsError::InvalidData)?;
records.push(Self::from_parts(parent, credential));
}
Ok(records)
}