implement in-memory server
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use async_trait::async_trait;
|
||||
use opaque_ke::ServerLogin;
|
||||
|
||||
@@ -2,7 +2,7 @@ use async_trait::async_trait;
|
||||
use std::marker::PhantomData;
|
||||
use uuid::Uuid;
|
||||
use opaque_ke::{CredentialFinalization, CredentialRequest, RegistrationRequest};
|
||||
use crate::shared::models::opaque::{NKodeCipherSuite, NKodeServerSetup, OpaqueLoginSession, OpaqueRegisterSession, PasswordFile};
|
||||
use crate::shared::models::opaque::{NKodeCipherSuite, OpaqueLoginSession, OpaqueRegisterSession, PasswordFile};
|
||||
use crate::client::opaque::{ClientAuthError, ServerConnectionLogin, ServerConnectionRegister};
|
||||
use crate::server::app::{Code, Key};
|
||||
use crate::server::app::ServerApp;
|
||||
@@ -12,30 +12,25 @@ use crate::server::repository::in_memory::in_memory_opaque_session::InMemoryOpaq
|
||||
use crate::server::repository::in_memory::in_memory_user_db::InMemoryUserDB;
|
||||
use crate::shared::models::app::LoggedInSession;
|
||||
|
||||
pub struct InMemoryServer<K: CredKind> {
|
||||
auth_db: ServerApp<InMemoryOpaqueDB, InMemoryOpaqueSession, InMemoryUserDB>,
|
||||
pub type InMemoryKeyServer<'a> = InMemoryServer<'a, Key>;
|
||||
pub type InMemoryCodeServer<'a> = InMemoryServer<'a, Code>;
|
||||
|
||||
pub struct InMemoryServer<'a, K: CredKind> {
|
||||
auth_db: &'a ServerApp<InMemoryOpaqueDB, InMemoryOpaqueSession, InMemoryUserDB>,
|
||||
_kind: PhantomData<K>,
|
||||
}
|
||||
|
||||
impl<K: CredKind> InMemoryServer<K> {
|
||||
pub fn new(server_setup: NKodeServerSetup) -> Self {
|
||||
impl<'a, K: CredKind> InMemoryServer<'a, K> {
|
||||
pub fn new(server_app: &'a ServerApp<InMemoryOpaqueDB, InMemoryOpaqueSession, InMemoryUserDB>) -> Self {
|
||||
Self {
|
||||
auth_db: ServerApp::new(
|
||||
server_setup,
|
||||
InMemoryOpaqueDB::new(),
|
||||
InMemoryOpaqueSession::new(),
|
||||
InMemoryUserDB::new()
|
||||
),
|
||||
auth_db: server_app,
|
||||
_kind: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type InMemoryKeyServer = InMemoryServer<Key>;
|
||||
pub type InMemoryCodeServer = InMemoryServer<Code>;
|
||||
|
||||
#[async_trait]
|
||||
impl<K> ServerConnectionRegister for InMemoryServer<K>
|
||||
impl<'a, K> ServerConnectionRegister for InMemoryServer<'a, K>
|
||||
where
|
||||
K: CredKind + Sync,
|
||||
{
|
||||
@@ -64,7 +59,7 @@ where
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<K> ServerConnectionLogin for InMemoryServer<K>
|
||||
impl<'a, K> ServerConnectionLogin for InMemoryServer<'a,K>
|
||||
where
|
||||
K: CredKind + Send + Sync,
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pub mod in_memory_opaque_db;
|
||||
pub mod in_memory_transport;
|
||||
pub mod in_memory_opaque_session;
|
||||
mod in_memory_user_db;
|
||||
pub mod in_memory_user_db;
|
||||
|
||||
Reference in New Issue
Block a user