Compare commits
1 Commits
persistent
...
27c2f467c4
Author | SHA1 | Date | |
---|---|---|---|
27c2f467c4 |
@ -148,43 +148,6 @@ impl AwsSessionCredential {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, FromRow)]
|
|
||||||
pub struct AwsSessionRow {
|
|
||||||
version: i64,
|
|
||||||
base_id: Uuid,
|
|
||||||
access_key_id: String,
|
|
||||||
session_token: String,
|
|
||||||
secret_key_enc: Vec<u8>,
|
|
||||||
nonce: Vec<u8>,
|
|
||||||
expiration: i64,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl PersistentCredential for AwsSessionCredential {
|
|
||||||
type Row = AwsSessionRow;
|
|
||||||
fn type_name() -> &'static str { "aws_session" }
|
|
||||||
fn into_credential(self) -> Credential { Credential::AwsSession(self) }
|
|
||||||
fn row_id(row: &AwsSessionRow) -> Uuid { row.base_id }
|
|
||||||
|
|
||||||
fn from_row(row: AwsSessionRow, crypto: &Crypto) -> Rsult<Self, LoadCredentialsError> {
|
|
||||||
let nonce = XNonce::clone_from_slice(&row.nonce);
|
|
||||||
let secret_key_bytes = crypto.decrypt(&nonce, &row.secret_key_enc)?;
|
|
||||||
let secret_access_key = String::from_utf8(secret_key_bytes)
|
|
||||||
.map_err(|_| LoadCredentialsError::InvalidData)?;
|
|
||||||
|
|
||||||
Ok(AwsSessionCredential {
|
|
||||||
version: row.version as usize,
|
|
||||||
access_key_id: row.access_key_id,
|
|
||||||
secret_access_key,
|
|
||||||
session_token: row.session_token,
|
|
||||||
expiration: DateTime::from_secs(row.expiration),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn save_details(&self, base_id: &Uuid, crypto: &Crypto, txn: &mut Transaction)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fn default_credentials_version() -> usize { 1 }
|
fn default_credentials_version() -> usize { 1 }
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,14 +11,15 @@ use creddy::{
|
|||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let res = match cli::parser().get_matches().subcommand() {
|
let global_matches = cli::parser().get_matches();
|
||||||
|
let res = match global_matches.subcommand() {
|
||||||
None | Some(("run", _)) => {
|
None | Some(("run", _)) => {
|
||||||
app::run().error_popup("Creddy encountered an error");
|
app::run().error_popup("Creddy encountered an error");
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
Some(("get", m)) => cli::get(m),
|
Some(("get", m)) => cli::get(m, &global_matches),
|
||||||
Some(("exec", m)) => cli::exec(m),
|
Some(("exec", m)) => cli::exec(m, &global_matches),
|
||||||
Some(("shortcut", m)) => cli::invoke_shortcut(m),
|
Some(("shortcut", m)) => cli::invoke_shortcut(m, &global_matches),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user