fix: update TOTP::new() call for totp-rs 5.7.0 API
- totp-rs 5.7.0 requires 7 arguments instead of 5 - Added issuer (Option<String>) and account_name (String) parameters - Fixes compilation error in veza-common/src/auth.rs
This commit is contained in:
parent
5bf5780439
commit
f004ff5ef1
1 changed files with 3 additions and 1 deletions
|
|
@ -343,7 +343,7 @@ pub fn generate_totp_secret() -> VezaResult<String> {
|
|||
pub fn validate_totp_code(secret: &str, code: &str, _window: i64) -> VezaResult<bool> {
|
||||
use totp_rs::{TOTP, Algorithm, Secret};
|
||||
|
||||
// totp-rs 5.4 API: TOTP::new takes 5 arguments: algorithm, digits, skew, step, secret
|
||||
// totp-rs 5.7 API: TOTP::new takes 7 arguments: algorithm, digits, skew, step, secret, issuer, account_name
|
||||
// Use Secret::Encoded to handle base32 string directly
|
||||
let secret_obj = Secret::Encoded(secret.to_string());
|
||||
|
||||
|
|
@ -354,6 +354,8 @@ pub fn validate_totp_code(secret: &str, code: &str, _window: i64) -> VezaResult<
|
|||
30,
|
||||
secret_obj.to_bytes()
|
||||
.map_err(|e| VezaError::Auth(format!("Invalid TOTP secret: {}", e)))?,
|
||||
Some("Veza".to_string()), // issuer
|
||||
"user".to_string(), // account_name (generic, can be customized)
|
||||
).map_err(|e| VezaError::Auth(format!("Invalid TOTP secret: {}", e)))?;
|
||||
|
||||
let is_valid = totp.check_current(code)
|
||||
|
|
|
|||
Loading…
Reference in a new issue