Skip to content

Commit b54bfbc

Browse files
authored
Merge pull request #141 from linux-credentials/iinuwa/app-name-optional
Make app name optional
2 parents 6b55ffe + 35cb362 commit b54bfbc

5 files changed

Lines changed: 48 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# [unreleased]
22

3+
## Breaking Changes
4+
5+
### UI Controller API
6+
7+
- Reordered parameters in RequestingApplication, and made app name optional.
8+
39
# [0.2.0] - 2025-02-18
410

511
## Breaking Changes

credentialsd-common/src/model.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Display;
22

33
use serde::{Deserialize, Serialize};
4-
use zvariant::{SerializeDict, Type};
4+
use zvariant::{Optional, SerializeDict, Type};
55

66
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
77
pub struct Credential {
@@ -96,10 +96,17 @@ impl Transport {
9696
}
9797
}
9898

99+
/// Details about the calling application to be displayed in the UI.
99100
#[derive(Debug, Default, Clone, Serialize, Deserialize, Type)]
100101
pub struct RequestingApplication {
101-
pub name: String,
102-
pub path: String,
102+
/// The App ID (if called on the portal interface) or path (if called on the
103+
/// internal interface).
104+
pub path_or_app_id: String,
105+
106+
/// The name of the application.
107+
pub name: Optional<String>,
108+
109+
/// The PID of the applicatoin
103110
pub pid: u32,
104111
}
105112

credentialsd-ui/src/gui/view_model/mod.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ where
3333
subtitle: String,
3434
operation: Operation,
3535
rp_id: String,
36-
requesting_app: RequestingApplication,
36+
app_name: String,
37+
app_path_or_id: String,
38+
app_pid: u32,
3739

3840
// This includes devices like platform authenticator, USB, hybrid
3941
devices: Vec<Device>,
@@ -52,13 +54,22 @@ impl<F: FlowController + Send> ViewModel<F> {
5254
rx_event: Receiver<ViewEvent>,
5355
tx_update: Sender<ViewUpdate>,
5456
) -> Self {
57+
let RequestingApplication {
58+
name: app_name,
59+
path_or_app_id: path,
60+
pid,
61+
} = request.requesting_app;
62+
63+
let app_name: Option<String> = app_name.into();
5564
Self {
5665
flow_controller,
5766
rx_event,
5867
tx_update,
5968
operation: request.operation,
6069
rp_id: request.rp_id,
61-
requesting_app: request.requesting_app,
70+
app_name: app_name.unwrap_or_else(|| gettext("unknown application")),
71+
app_path_or_id: path,
72+
app_pid: pid,
6273
title: String::default(),
6374
subtitle: String::default(),
6475
devices: Vec::new(),
@@ -69,11 +80,6 @@ impl<F: FlowController + Send> ViewModel<F> {
6980
}
7081

7182
async fn update_title(&mut self) {
72-
let mut requesting_app = self.requesting_app.clone();
73-
74-
if requesting_app.name.is_empty() {
75-
requesting_app.name = gettext("unknown application");
76-
};
7783
let mut title = match self.operation {
7884
Operation::Create => {
7985
// TRANSLATORS: %s1 is the "relying party" (think: domain name) where the request is coming from
@@ -105,9 +111,9 @@ impl<F: FlowController + Send> ViewModel<F> {
105111
}
106112
.to_string();
107113
subtitle = subtitle.replace("%s1", &self.rp_id);
108-
subtitle = subtitle.replace("%i1", &format!("{}", requesting_app.pid));
109-
subtitle = subtitle.replace("%s2", &requesting_app.name);
110-
subtitle = subtitle.replace("%s3", &requesting_app.path);
114+
subtitle = subtitle.replace("%i1", &format!("{}", self.app_pid));
115+
subtitle = subtitle.replace("%s2", &self.app_name);
116+
subtitle = subtitle.replace("%s3", &self.app_path_or_id);
111117
self.title = title;
112118
self.subtitle = subtitle;
113119
self.tx_update

credentialsd/src/dbus/gateway.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ async fn query_connection_peer_binary(
208208
tracing::debug!("Request is from: {exe_path:?}");
209209

210210
Some(RequestingApplication {
211-
name: command_name,
212-
path: exe_path.to_string_lossy().to_string(),
211+
name: Some(command_name).into(),
212+
path_or_app_id: exe_path.to_string_lossy().to_string(),
213213
pid,
214214
})
215215
}
@@ -451,8 +451,8 @@ async fn validate_app_details(
451451
NavigationContext::SameOrigin(Origin::AppId(app_id))
452452
};
453453
let app_details = RequestingApplication {
454-
name: display_name,
455-
path: claimed_app_id,
454+
name: Some(display_name).into(),
455+
path_or_app_id: claimed_app_id,
456456
pid,
457457
};
458458
Ok((app_details, request_env))

doc/api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,9 @@ This method should be called when a new credential request begins.
881881
ViewRequest: [a{sv}] {
882882
id: u,
883883
operation: Operation,
884+
rp_id: s,
885+
requesting_app: RequestingApplication,
886+
window_handle: s, // Optional
884887
}
885888
```
886889

@@ -891,6 +894,15 @@ Operation[s] [
891894
]
892895
```
893896

897+
```
898+
RequestingApplication {
899+
name: s, // Optional
900+
path_or_app_id: s,
901+
pid: u32,
902+
903+
}
904+
```
905+
894906
### Response
895907

896908
None.

0 commit comments

Comments
 (0)