Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# [unreleased]

## Breaking Changes

### UI Controller API

- Reordered parameters in RequestingApplication, and made app name optional.

# [0.2.0] - 2025-02-18

## Breaking Changes
Expand Down
13 changes: 10 additions & 3 deletions credentialsd-common/src/model.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::Display;

use serde::{Deserialize, Serialize};
use zvariant::{SerializeDict, Type};
use zvariant::{Optional, SerializeDict, Type};

#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Credential {
Expand Down Expand Up @@ -96,10 +96,17 @@ impl Transport {
}
}

/// Details about the calling application to be displayed in the UI.
#[derive(Debug, Default, Clone, Serialize, Deserialize, Type)]
pub struct RequestingApplication {
pub name: String,
pub path: String,
/// The App ID (if called on the portal interface) or path (if called on the
/// internal interface).
pub path_or_app_id: String,

/// The name of the application.
pub name: Optional<String>,

/// The PID of the applicatoin
pub pid: u32,
}

Expand Down
26 changes: 16 additions & 10 deletions credentialsd-ui/src/gui/view_model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ where
subtitle: String,
operation: Operation,
rp_id: String,
requesting_app: RequestingApplication,
app_name: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason to unbundle this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember details right now, but it helped to allow moving the strings instead of cloning.

app_path_or_id: String,
app_pid: u32,

// This includes devices like platform authenticator, USB, hybrid
devices: Vec<Device>,
Expand All @@ -52,13 +54,22 @@ impl<F: FlowController + Send> ViewModel<F> {
rx_event: Receiver<ViewEvent>,
tx_update: Sender<ViewUpdate>,
) -> Self {
let RequestingApplication {
name: app_name,
path_or_app_id: path,
pid,
} = request.requesting_app;

let app_name: Option<String> = app_name.into();
Self {
flow_controller,
rx_event,
tx_update,
operation: request.operation,
rp_id: request.rp_id,
requesting_app: request.requesting_app,
app_name: app_name.unwrap_or_else(|| gettext("unknown application")),
app_path_or_id: path,
app_pid: pid,
title: String::default(),
subtitle: String::default(),
devices: Vec::new(),
Expand All @@ -69,11 +80,6 @@ impl<F: FlowController + Send> ViewModel<F> {
}

async fn update_title(&mut self) {
let mut requesting_app = self.requesting_app.clone();

if requesting_app.name.is_empty() {
requesting_app.name = gettext("unknown application");
};
let mut title = match self.operation {
Operation::Create => {
// TRANSLATORS: %s1 is the "relying party" (think: domain name) where the request is coming from
Expand Down Expand Up @@ -105,9 +111,9 @@ impl<F: FlowController + Send> ViewModel<F> {
}
.to_string();
subtitle = subtitle.replace("%s1", &self.rp_id);
subtitle = subtitle.replace("%i1", &format!("{}", requesting_app.pid));
subtitle = subtitle.replace("%s2", &requesting_app.name);
subtitle = subtitle.replace("%s3", &requesting_app.path);
subtitle = subtitle.replace("%i1", &format!("{}", self.app_pid));
subtitle = subtitle.replace("%s2", &self.app_name);
subtitle = subtitle.replace("%s3", &self.app_path_or_id);
self.title = title;
self.subtitle = subtitle;
self.tx_update
Expand Down
8 changes: 4 additions & 4 deletions credentialsd/src/dbus/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ async fn query_connection_peer_binary(
tracing::debug!("Request is from: {exe_path:?}");

Some(RequestingApplication {
name: command_name,
path: exe_path.to_string_lossy().to_string(),
name: Some(command_name).into(),
path_or_app_id: exe_path.to_string_lossy().to_string(),
pid,
})
}
Expand Down Expand Up @@ -451,8 +451,8 @@ async fn validate_app_details(
NavigationContext::SameOrigin(Origin::AppId(app_id))
};
let app_details = RequestingApplication {
name: display_name,
path: claimed_app_id,
name: Some(display_name).into(),
path_or_app_id: claimed_app_id,
pid,
};
Ok((app_details, request_env))
Expand Down
12 changes: 12 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,9 @@ This method should be called when a new credential request begins.
ViewRequest: [a{sv}] {
id: u,
operation: Operation,
rp_id: s,
requesting_app: RequestingApplication,
window_handle: s, // Optional
}
```

Expand All @@ -891,6 +894,15 @@ Operation[s] [
]
```

```
RequestingApplication {
name: s, // Optional
path_or_app_id: s,
pid: u32,

}
```

### Response

None.
Expand Down