feat(gui): bus client policy + recovery method wrappers
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,8 @@
|
|||||||
//! `glib::MainContext::spawn_local`, which polls the future on the GTK main
|
//! `glib::MainContext::spawn_local`, which polls the future on the GTK main
|
||||||
//! thread; tokio's reactor wakes the future when zbus I/O is ready.
|
//! thread; tokio's reactor wakes the future when zbus I/O is ready.
|
||||||
|
|
||||||
use authforge_common::types::{Credential, PendingStatus};
|
use authforge_common::policy::Policy;
|
||||||
|
use authforge_common::types::{Credential, PendingStatus, PolicyApplyResult, RecoveryCodeSummary};
|
||||||
|
|
||||||
const BUS_NAME: &str = "io.dangerousthings.AuthForge";
|
const BUS_NAME: &str = "io.dangerousthings.AuthForge";
|
||||||
const OBJECT_PATH: &str = "/io/dangerousthings/AuthForge";
|
const OBJECT_PATH: &str = "/io/dangerousthings/AuthForge";
|
||||||
@@ -56,6 +57,35 @@ impl Daemon {
|
|||||||
pub async fn clear_pending_flag(&self, user: &str) -> zbus::Result<()> {
|
pub async fn clear_pending_flag(&self, user: &str) -> zbus::Result<()> {
|
||||||
self.proxy.call("ClearPendingFlag", &(user,)).await
|
self.proxy.call("ClearPendingFlag", &(user,)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_policy(&self) -> zbus::Result<Policy> {
|
||||||
|
self.proxy.call("GetPolicy", &()).await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `force=false` runs the daemon's lockout simulator first; on
|
||||||
|
/// violations, returns `PolicyApplyResult { applied: false, violations }`
|
||||||
|
/// without writing.
|
||||||
|
pub async fn set_policy(&self, p: &Policy, force: bool) -> zbus::Result<PolicyApplyResult> {
|
||||||
|
self.proxy.call("SetPolicy", &(p, force)).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn generate_recovery_code(&self, user: &str) -> zbus::Result<String> {
|
||||||
|
self.proxy.call("GenerateRecoveryCode", &(user,)).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn list_recovery_codes(&self) -> zbus::Result<Vec<RecoveryCodeSummary>> {
|
||||||
|
self.proxy.call("ListRecoveryCodes", &()).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn revoke_recovery_code(&self, user: &str) -> zbus::Result<bool> {
|
||||||
|
self.proxy.call("RevokeRecoveryCode", &(user,)).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn subscribe_policy_changed(
|
||||||
|
&self,
|
||||||
|
) -> zbus::Result<zbus::proxy::SignalStream<'static>> {
|
||||||
|
self.proxy.receive_signal("PolicyChanged").await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)] // wired through keys_page.rs in Task 4.
|
#[allow(dead_code)] // wired through keys_page.rs in Task 4.
|
||||||
|
|||||||
Reference in New Issue
Block a user