Compare commits
2 Commits
d796956c0c
...
23336c9310
Author | SHA1 | Date | |
---|---|---|---|
23336c9310 | |||
e5c6f0d372 |
@ -22,7 +22,7 @@ bcrypt = "0.17.0"
|
|||||||
uuid = { version = "1.16.0", features = ["v4"] }
|
uuid = { version = "1.16.0", features = ["v4"] }
|
||||||
mime_guess = "2.0.5"
|
mime_guess = "2.0.5"
|
||||||
askama = "0.14.0"
|
askama = "0.14.0"
|
||||||
futures-util = "0.3.30"
|
futures-util = "0.3.31"
|
||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
rand = "0.9.1"
|
rand = "0.9.1"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::io::ErrorKind;
|
|
||||||
|
|
||||||
use base32::Alphabet;
|
use base32::Alphabet;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use totp_rfc6238::{HashAlgorithm, TotpGenerator};
|
use totp_rfc6238::{HashAlgorithm, TotpGenerator};
|
||||||
@ -90,8 +88,7 @@ impl TotpKey {
|
|||||||
|
|
||||||
let key = match base32::decode(BASE32_ALPHABET, &self.encoded) {
|
let key = match base32::decode(BASE32_ALPHABET, &self.encoded) {
|
||||||
None => {
|
None => {
|
||||||
return Err(Box::new(std::io::Error::new(
|
return Err(Box::new(std::io::Error::other(
|
||||||
ErrorKind::Other,
|
|
||||||
"Failed to decode base32 secret!",
|
"Failed to decode base32 secret!",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use std::io::ErrorKind;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use actix_web::web;
|
use actix_web::web;
|
||||||
@ -109,15 +108,13 @@ impl WebAuthManager {
|
|||||||
) -> Res<WebauthnPubKey> {
|
) -> Res<WebauthnPubKey> {
|
||||||
let state: RegisterKeyOpaqueData = self.crypto_wrapper.decrypt(opaque_state)?;
|
let state: RegisterKeyOpaqueData = self.crypto_wrapper.decrypt(opaque_state)?;
|
||||||
if state.user_id != user.uid {
|
if state.user_id != user.uid {
|
||||||
return Err(Box::new(std::io::Error::new(
|
return Err(Box::new(std::io::Error::other(
|
||||||
ErrorKind::Other,
|
|
||||||
"Invalid user for pubkey!",
|
"Invalid user for pubkey!",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if state.expire < time() {
|
if state.expire < time() {
|
||||||
return Err(Box::new(std::io::Error::new(
|
return Err(Box::new(std::io::Error::other(
|
||||||
ErrorKind::Other,
|
|
||||||
"Challenge has expired!",
|
"Challenge has expired!",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@ -157,15 +154,13 @@ impl WebAuthManager {
|
|||||||
) -> Res {
|
) -> Res {
|
||||||
let state: AuthStateOpaqueData = self.crypto_wrapper.decrypt(opaque_state)?;
|
let state: AuthStateOpaqueData = self.crypto_wrapper.decrypt(opaque_state)?;
|
||||||
if &state.user_id != user_id {
|
if &state.user_id != user_id {
|
||||||
return Err(Box::new(std::io::Error::new(
|
return Err(Box::new(std::io::Error::other(
|
||||||
ErrorKind::Other,
|
|
||||||
"Invalid user for pubkey!",
|
"Invalid user for pubkey!",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if state.expire < time() {
|
if state.expire < time() {
|
||||||
return Err(Box::new(std::io::Error::new(
|
return Err(Box::new(std::io::Error::other(
|
||||||
ErrorKind::Other,
|
|
||||||
"Challenge has expired!",
|
"Challenge has expired!",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user