Showing the TOTP URI to the user when doing a TOTP cred reset (#855)

* Console TOTP registration - present registration URI to the user (Fixes #853)
* 📎-happiness
This commit is contained in:
James Hodgkinson 2022-06-26 18:08:24 +10:00 committed by GitHub
parent 57f8fa9d2b
commit 2be83a635d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View file

@ -505,8 +505,7 @@ impl KanidmClient {
let mut sguard = self.auth_session_id.write().await;
*sguard = headers
.get(KSESSIONID)
.map(|hv| hv.to_str().ok().map(str::to_string))
.flatten();
.and_then(|hv| hv.to_str().ok().map(str::to_string));
}
let opid = headers

View file

@ -551,7 +551,7 @@ async fn totp_enroll_prompt(session_token: &CUSessionToken, client: &KanidmClien
};
// gen the qr
eprintln!("Scan the following QR code with your OTP app.");
println!("Scan the following QR code with your OTP app.");
let code = match QrCode::new(totp_secret.to_uri().as_str()) {
Ok(c) => c,
@ -565,9 +565,11 @@ async fn totp_enroll_prompt(session_token: &CUSessionToken, client: &KanidmClien
.dark_color(unicode::Dense1x2::Light)
.light_color(unicode::Dense1x2::Dark)
.build();
eprintln!("{}", image);
println!("{}", image);
eprintln!("Alternatively, you can manually enter the following OTP details:");
println!("Alternatively, you can manually enter the following OTP details:");
println!("--------------------------------------------------------------");
println!("TOTP URI: {}", totp_secret.to_uri().as_str());
println!("Account Name: {}", totp_secret.accountname);
println!("Issuer: {}", totp_secret.issuer);
println!("Algorithm: {}", totp_secret.algo);
@ -575,8 +577,8 @@ async fn totp_enroll_prompt(session_token: &CUSessionToken, client: &KanidmClien
println!("Secret: {}", totp_secret.get_secret());
// prompt for the totp.
eprintln!("--------------------------------------------------------------");
eprintln!("Enter a TOTP from your authenticator to complete registration:");
println!("--------------------------------------------------------------");
println!("Enter a TOTP from your authenticator to complete registration:");
// Up to three attempts
let mut attempts = 3;