update rpassword to 7.2.0 and add some debug logs (#325)

related: #324
This commit is contained in:
Carson McManus 2023-09-28 17:12:50 -04:00 committed by GitHub
parent 4fb0e4cfcd
commit 04295dc742
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 10 deletions

15
Cargo.lock generated
View file

@ -2476,11 +2476,12 @@ dependencies = [
[[package]] [[package]]
name = "rpassword" name = "rpassword"
version = "5.0.1" version = "7.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffc936cf8a7ea60c58f030fd36a612a48f440610214dc54bc36431f9ea0c3efb" checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322"
dependencies = [ dependencies = [
"libc", "libc",
"rtoolbox",
"winapi", "winapi",
] ]
@ -2506,6 +2507,16 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "rtoolbox"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a"
dependencies = [
"libc",
"winapi",
]
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.23" version = "0.1.23"

View file

@ -33,7 +33,7 @@ path = "src/main.rs"
anyhow = "^1.0" anyhow = "^1.0"
base64 = "0.21.2" base64 = "0.21.2"
text_io = "0.1.8" text_io = "0.1.8"
rpassword = "5.0" rpassword = "7.2.0"
reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "cookies", "gzip", "rustls-tls"] } reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "cookies", "gzip", "rustls-tls"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"

View file

@ -25,8 +25,7 @@ where
error!("Passkey cannot be empty, try again."); error!("Passkey cannot be empty, try again.");
continue; continue;
} }
let passkey_confirm = let passkey_confirm = rpassword::prompt_password("Confirm encryption passkey: ")
rpassword::prompt_password_stdout("Confirm encryption passkey: ")
.map(SecretString::new)?; .map(SecretString::new)?;
if passkey1.expose_secret() == passkey_confirm.expose_secret() { if passkey1.expose_secret() == passkey_confirm.expose_secret() {
passkey = Some(passkey1); passkey = Some(passkey1);

View file

@ -82,6 +82,7 @@ fn do_login_impl<T: Transport + Clone>(
password: SecretString, password: SecretString,
account: Option<&SteamGuardAccount>, account: Option<&SteamGuardAccount>,
) -> anyhow::Result<Tokens> { ) -> anyhow::Result<Tokens> {
debug!("starting login");
let mut login = UserLogin::new(transport.clone(), build_device_details()); let mut login = UserLogin::new(transport.clone(), build_device_details());
let mut password = password; let mut password = password;

View file

@ -1,3 +1,4 @@
use anyhow::Context;
use crossterm::{ use crossterm::{
cursor, cursor,
event::{Event, KeyCode, KeyEvent, KeyModifiers}, event::{Event, KeyCode, KeyEvent, KeyModifiers},
@ -6,6 +7,7 @@ use crossterm::{
terminal::{Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen}, terminal::{Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen},
QueueableCommand, QueueableCommand,
}; };
use log::debug;
use secrecy::SecretString; use secrecy::SecretString;
use std::collections::HashSet; use std::collections::HashSet;
use std::io::{stderr, stdout, Write}; use std::io::{stderr, stdout, Write};
@ -245,18 +247,21 @@ pub(crate) fn pause() {
} }
} }
pub(crate) fn prompt_passkey() -> std::io::Result<SecretString> { pub(crate) fn prompt_passkey() -> anyhow::Result<SecretString> {
debug!("prompting for passkey");
loop { loop {
let raw = rpassword::prompt_password_stdout("Enter encryption passkey: ")?; let raw = rpassword::prompt_password("Enter encryption passkey: ")
.context("prompting for passkey")?;
if !raw.is_empty() { if !raw.is_empty() {
return Ok(SecretString::new(raw)); return Ok(SecretString::new(raw));
} }
} }
} }
pub(crate) fn prompt_password() -> std::io::Result<SecretString> { pub(crate) fn prompt_password() -> anyhow::Result<SecretString> {
debug!("prompting for password");
loop { loop {
let raw = rpassword::prompt_password_stdout("Password: ")?; let raw = rpassword::prompt_password("Password: ").context("prompting for password")?;
if !raw.is_empty() { if !raw.is_empty() {
return Ok(SecretString::new(raw)); return Ok(SecretString::new(raw));
} }