1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Can generate admin key enrollment challenge

This commit is contained in:
2021-05-14 09:30:59 +02:00
parent 158d35171d
commit 70860ab184
11 changed files with 147 additions and 11 deletions

View File

@ -13,7 +13,7 @@ use crate::utils::date_utils::time;
static mut CACHE: Option<Arc<Mutex<HashMap<AdminID, AdminAccessToken>>>> = None;
/// Initialize this helper
/// Initialize this helper's cache
pub fn init() {
unsafe {
let map = HashMap::new();

View File

@ -0,0 +1,34 @@
//! # Administrators key registration challenges helper
//!
//! Allows to temporarily stores keys registration challenges
//!
//! @author Pierre Hubert
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use webauthn_rs::RegistrationState;
use crate::data::admin::AdminID;
use crate::data::error::Res;
static mut CACHE: Option<Arc<Mutex<HashMap<AdminID, RegistrationState>>>> = None;
/// Initialize this helper's cache
pub fn init() {
unsafe {
let map = HashMap::new();
CACHE = Some(Arc::new(Mutex::new(map)));
}
}
/// Store a new entry in the cache
pub fn set(admin: AdminID, key: RegistrationState) -> Res {
let cache = unsafe {
CACHE.as_ref().unwrap().lock()
};
cache?.insert(admin, key);
Ok(())
}

View File

@ -23,4 +23,5 @@ pub mod independent_push_notifications_service_helper;
pub mod firebase_notifications_helper;
pub mod forez_presence_helper;
pub mod admin_account_helper;
pub mod admin_access_token_helper;
pub mod admin_access_token_helper;
pub mod admin_key_registration_challenges_helper;