2fa for unattended access

This commit is contained in:
rustdesk
2024-01-19 15:35:58 +08:00
parent 80857c22c9
commit 44e6b7dbb0
55 changed files with 673 additions and 60 deletions

View File

@@ -180,6 +180,15 @@ pub fn session_login(
}
}
pub fn session_send2fa(
session_id: SessionID,
code: String,
) {
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
session.send2fa(code);
}
}
pub fn session_close(session_id: SessionID) {
if let Some(session) = sessions::remove_session_by_session_id(&session_id) {
session.close_event_stream(session_id);
@@ -2016,6 +2025,23 @@ pub fn main_supported_input_source() -> SyncReturn<String> {
}
}
pub fn main_generate2fa() -> String {
crate::auth_2fa::generate2fa()
}
pub fn main_verify2fa(code: String) -> bool {
let res = crate::auth_2fa::verify2fa(code);
if res {
refresh_options();
}
res
}
pub fn main_has_valid_2fa_sync() -> SyncReturn<bool> {
let raw = get_option("2fa");
SyncReturn(crate::auth_2fa::get_2fa(Some(raw)).is_some())
}
#[cfg(target_os = "android")]
pub mod server_side {
use hbb_common::{config, log};