1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-04-18 10:30:53 +00:00
comunicapiv3/src/data/webauthn_config.rs

36 lines
809 B
Rust

//! # Webauthn config
//!
//! @author Pierre Hubert
use webauthn_rs::{Webauthn, WebauthnConfig};
use crate::data::config::conf;
pub struct ComunicAdminWebauthnConfig {}
impl WebauthnConfig for ComunicAdminWebauthnConfig {
fn get_relying_party_name(&self) -> String {
"ComunicAdmin".to_string()
}
fn get_origin(&self) -> &String {
&conf().admin_url
}
fn get_relying_party_id(&self) -> String {
self.get_origin()
.replace("https://", "")
.replace("http://", "")
.split(":")
.next()
.unwrap()
.split("/")
.next()
.unwrap()
.to_string()
}
}
pub fn get_wan() -> Webauthn<ComunicAdminWebauthnConfig> {
Webauthn::new(ComunicAdminWebauthnConfig {})
}