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:
@ -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();
|
||||
|
34
src/helpers/admin_key_registration_challenges_helper.rs
Normal file
34
src/helpers/admin_key_registration_challenges_helper.rs
Normal 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(())
|
||||
}
|
@ -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;
|
Reference in New Issue
Block a user