Skip to content

Commit b177ddb

Browse files
committed
daemon: Add some documentation to D-Bus gateway service
1 parent b3462cf commit b177ddb

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

credentialsd/src/dbus/flow_control.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ enum SignalState {
341341
Active,
342342
}
343343

344+
/// Coordinates between user and various devices connected to the machine to
345+
/// fulfill credential requests.
344346
#[async_trait]
345347
pub trait CredentialRequestController {
346348
async fn request_credential(

credentialsd/src/gateway/dbus.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,28 @@ pub(super) async fn start_dbus_gateway(
3535
tracing::error!("Failed to connect to D-Bus session: {err}");
3636
})?
3737
.name(SERVICE_NAME)?
38-
.serve_at(SERVICE_PATH, CredentialGateway { svc: svc.clone() })?
38+
.serve_at(
39+
SERVICE_PATH,
40+
CredentialGateway {
41+
gateway_service: svc.clone(),
42+
},
43+
)?
3944
.build()
4045
.await
4146
}
4247

48+
/// Struct to hold state for the D-Bus interface.
4349
struct CredentialGateway {
44-
svc: Arc<AsyncMutex<GatewayService>>,
50+
/// Service responsible for processing credential requests.
51+
gateway_service: Arc<AsyncMutex<GatewayService>>,
4552
}
4653

47-
/// These are public methods that can be called by arbitrary clients to begin a credential flow.
54+
/// These are public methods that can be called by arbitrary clients to begin a
55+
/// credential flow.
56+
///
57+
/// The D-Bus interface is responsible for authorizing the client and collecting
58+
/// the contextual information about the client to pass onto the GatewayService
59+
/// for evaluation.
4860
#[interface(name = "xyz.iinuwa.credentialsd.Credentials1")]
4961
impl CredentialGateway {
5062
async fn create_credential(
@@ -83,7 +95,7 @@ impl CredentialGateway {
8395
// Find out where this request is coming from (which application is requesting this)
8496
let requesting_app = query_connection_peer_binary(header, connection).await;
8597
let response = self
86-
.svc
98+
.gateway_service
8799
.lock()
88100
.await
89101
.handle_create_credential(
@@ -132,7 +144,7 @@ impl CredentialGateway {
132144
// Find out where this request is coming from (which application is requesting this)
133145
let requesting_app = query_connection_peer_binary(header, connection).await;
134146
let response = self
135-
.svc
147+
.gateway_service
136148
.lock()
137149
.await
138150
.handle_get_credential(
@@ -146,7 +158,11 @@ impl CredentialGateway {
146158
}
147159

148160
async fn get_client_capabilities(&self) -> fdo::Result<GetClientCapabilitiesResponse> {
149-
let capabilities = self.svc.lock().await.handle_get_client_capabilities();
161+
let capabilities = self
162+
.gateway_service
163+
.lock()
164+
.await
165+
.handle_get_client_capabilities();
150166
Ok(capabilities)
151167
}
152168
}

credentialsd/src/gateway/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ pub async fn start_gateway<C: CredentialRequestController + Send + Sync + 'stati
3535
dbus::start_dbus_gateway(svc).await
3636
}
3737

38+
/// Service responsible for processing credential requests received from various
39+
/// client interfaces.
3840
struct GatewayService {
41+
/// Coordinates between user and various devices connected to the machine to
42+
/// fulfill credential requests.
3943
request_controller: Box<dyn CredentialRequestController + Send + Sync>,
4044
}
4145

0 commit comments

Comments
 (0)