35 lines
1.4 KiB
Rust
35 lines
1.4 KiB
Rust
use uuid::Uuid;
|
|
use opaque_ke::ServerLogin;
|
|
use crate::server::models::{LoginCache, RegCache};
|
|
use crate::shared::models::opaque::{NKodeCipherSuite, PasswordFile};
|
|
#[derive(Debug)]
|
|
pub enum AuthRepoError {
|
|
UserExists,
|
|
KeyNotRegistered,
|
|
CodeNotRegistered,
|
|
}
|
|
|
|
pub trait OpaqueDatabaseRepo {
|
|
fn new_key(&mut self, identifier: &[u8], password_file: PasswordFile) -> Result<(), AuthRepoError>;
|
|
fn new_code(&mut self, identifier: &[u8], password_file: PasswordFile) -> Result<(), AuthRepoError>;
|
|
|
|
fn has_code(&self, identifier: &[u8]) -> bool;
|
|
fn has_key(&self, identifier: &[u8]) -> bool;
|
|
|
|
fn get_key_passcode_file(&self, identifier: &[u8]) -> Result<PasswordFile, AuthRepoError>;
|
|
fn get_code_passcode_file(&self, identifier: &[u8]) -> Result<PasswordFile, AuthRepoError>;
|
|
}
|
|
|
|
pub trait OpaqueSessionRepo {
|
|
fn new_reg_session(&mut self, identifier: &[u8]) -> Result<RegCache, String>;
|
|
fn get_reg_session(&self, session_id: &Uuid) -> Result<RegCache, String>;
|
|
fn clear_reg_session(&mut self, session_id: &Uuid) -> Result<(), String>;
|
|
|
|
fn new_login_session(
|
|
&mut self,
|
|
identifier: &[u8],
|
|
server_login: ServerLogin<NKodeCipherSuite>,
|
|
) -> Result<LoginCache, String>;
|
|
fn get_login_session(&self, session_id: &Uuid) -> Result<LoginCache, String>;
|
|
fn clear_login_session(&mut self, session_id: &Uuid) -> Result<(), String>;
|
|
} |