Skip to content

Commit

Permalink
Merge pull request fedimint#6596 from tvolk131/gateway_cli_password_h…
Browse files Browse the repository at this point in the history
…ash_command

feat: gateway CLI can generate bcrypt password hashes
  • Loading branch information
tvolk131 authored Dec 21, 2024
2 parents 5d50f51 + 5f35397 commit 840f993
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gateway/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ path = "src/main.rs"

[dependencies]
anyhow = { workspace = true }
bcrypt = { workspace = true }
bitcoin = { workspace = true }
clap = { workspace = true }
clap_complete = "4.5.38"
Expand Down
12 changes: 12 additions & 0 deletions gateway/cli/src/general_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ pub enum GeneralCommands {
#[clap(long)]
event_kinds: Vec<EventKind>,
},
/// Create a bcrypt hash of a password, for use in gateway deployment
CreatePasswordHash {
password: String,

/// The bcrypt cost factor to use when hashing the password
#[clap(long)]
cost: Option<u32>,
},
}

impl GeneralCommands {
Expand Down Expand Up @@ -124,6 +132,10 @@ impl GeneralCommands {
.await?;
print_response(payment_log);
}
Self::CreatePasswordHash { password, cost } => print_response(
bcrypt::hash(password, cost.unwrap_or(bcrypt::DEFAULT_COST))
.expect("Unable to create bcrypt hash"),
),
}

Ok(())
Expand Down

0 comments on commit 840f993

Please sign in to comment.