Skip to content

Commit

Permalink
Support keys add for secure store
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Dec 6, 2024
1 parent f3370b4 commit fe02078
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions cmd/soroban-cli/src/config/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,25 @@ pub enum Error {
pub struct Args {
/// Add using `secret_key`
/// Can provide with `SOROBAN_SECRET_KEY`
#[arg(long, conflicts_with = "seed_phrase")]
#[arg(long, conflicts_with = "seed_phrase", conflicts_with = "secure_store")]
pub secret_key: bool,

/// Add using 12 word seed phrase to generate `secret_key`
#[arg(long, conflicts_with = "secret_key")]
#[arg(long, conflicts_with = "secret_key", conflicts_with = "secure_store")]
pub seed_phrase: bool,

/// Add using secure store entry
#[arg(
long,
requires = "entry_name",
conflicts_with = "seed_phrase",
conflicts_with = "secret_key"
)]
pub secure_store: bool,

/// Name of the secure store entry
#[arg(long, requires = "secure_store")]
pub entry_name: Option<String>,
}

impl Args {
Expand Down Expand Up @@ -71,6 +85,17 @@ impl Args {
.collect::<Vec<_>>()
.join(" "),
})
} else if self.secure_store {
let entry_name_with_prefix = format!(
"{}{}-{}",
keyring::SECURE_STORE_ENTRY_PREFIX,
keyring::SECURE_STORE_ENTRY_SERVICE,
self.entry_name.as_ref().unwrap()
);

Ok(Secret::SecureStore {
entry_name: entry_name_with_prefix,
})
} else {
Err(Error::PasswordRead {})
}
Expand Down

0 comments on commit fe02078

Please sign in to comment.