Compare commits
1 Commits
27c2f467c4
...
persistent
Author | SHA1 | Date | |
---|---|---|---|
87a037b9e6 |
@ -148,6 +148,43 @@ 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 }
|
||||
|
||||
|
||||
|
@ -11,15 +11,14 @@ use creddy::{
|
||||
|
||||
|
||||
fn main() {
|
||||
let global_matches = cli::parser().get_matches();
|
||||
let res = match global_matches.subcommand() {
|
||||
let res = match cli::parser().get_matches().subcommand() {
|
||||
None | Some(("run", _)) => {
|
||||
app::run().error_popup("Creddy encountered an error");
|
||||
Ok(())
|
||||
},
|
||||
Some(("get", m)) => cli::get(m, &global_matches),
|
||||
Some(("exec", m)) => cli::exec(m, &global_matches),
|
||||
Some(("shortcut", m)) => cli::invoke_shortcut(m, &global_matches),
|
||||
Some(("get", m)) => cli::get(m),
|
||||
Some(("exec", m)) => cli::exec(m),
|
||||
Some(("shortcut", m)) => cli::invoke_shortcut(m),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user