Skip to content

Commit 840f993

Browse files
authored
Merge pull request fedimint#6596 from tvolk131/gateway_cli_password_hash_command
feat: gateway CLI can generate bcrypt password hashes
2 parents 5d50f51 + 5f35397 commit 840f993

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gateway/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ path = "src/main.rs"
2020

2121
[dependencies]
2222
anyhow = { workspace = true }
23+
bcrypt = { workspace = true }
2324
bitcoin = { workspace = true }
2425
clap = { workspace = true }
2526
clap_complete = "4.5.38"

gateway/cli/src/general_commands.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ pub enum GeneralCommands {
5050
#[clap(long)]
5151
event_kinds: Vec<EventKind>,
5252
},
53+
/// Create a bcrypt hash of a password, for use in gateway deployment
54+
CreatePasswordHash {
55+
password: String,
56+
57+
/// The bcrypt cost factor to use when hashing the password
58+
#[clap(long)]
59+
cost: Option<u32>,
60+
},
5361
}
5462

5563
impl GeneralCommands {
@@ -124,6 +132,10 @@ impl GeneralCommands {
124132
.await?;
125133
print_response(payment_log);
126134
}
135+
Self::CreatePasswordHash { password, cost } => print_response(
136+
bcrypt::hash(password, cost.unwrap_or(bcrypt::DEFAULT_COST))
137+
.expect("Unable to create bcrypt hash"),
138+
),
127139
}
128140

129141
Ok(())

0 commit comments

Comments
 (0)