use crate::attestation::AttestationPolicy;
#[derive(Debug, Clone)]
pub struct WebauthnConfig {
pub rp_id: String,
pub rp_name: String,
pub rp_origins: Vec<String>,
pub allowed_algorithms: Vec<i32>,
pub challenge_timeout_secs: u64,
pub attestation: AttestationPolicy,
}
impl Default for WebauthnConfig {
fn default() -> Self {
Self {
rp_id: "localhost".to_string(),
rp_name: "webauthn-kit".to_string(),
rp_origins: vec!["http://localhost:8080".to_string()],
allowed_algorithms: vec![-7, -257],
challenge_timeout_secs: 300,
attestation: AttestationPolicy::default(),
}
}
}
#[allow(
clippy::unwrap_used,
clippy::expect_used,
clippy::indexing_slicing,
clippy::panic
)]
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_config_default() {
let config = WebauthnConfig::default();
assert_eq!(config.rp_id, "localhost");
assert_eq!(config.rp_name, "webauthn-kit");
assert_eq!(config.rp_origins, vec!["http://localhost:8080"]);
assert_eq!(config.allowed_algorithms, vec![-7, -257]);
assert_eq!(config.challenge_timeout_secs, 300);
}
#[test]
fn test_config_custom_algorithms() {
let config = WebauthnConfig {
allowed_algorithms: vec![-7],
..WebauthnConfig::default()
};
assert_eq!(config.allowed_algorithms.len(), 1);
assert_eq!(config.allowed_algorithms[0], -7);
}
}