Skip to content

Commit 69dd579

Browse files
committed
Show more request context in the UI (fix #69)
1 parent 735b49e commit 69dd579

File tree

9 files changed

+178
-52
lines changed

9 files changed

+178
-52
lines changed

credentialsd-common/src/server.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ where
484484
pub struct ViewRequest {
485485
pub operation: Operation,
486486
pub id: RequestId,
487+
pub rp_id: String,
488+
pub requesting_app: String,
487489
}
488490

489491
fn value_to_owned(value: &Value<'_>) -> OwnedValue {

credentialsd-ui/po/credentialsd-ui.pot

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ msgstr ""
33
"Project-Id-Version: credentialsd-ui\n"
44
"Report-Msgid-Bugs-To: \"https://github.com/linux-credentials/credentialsd/"
55
"issues\"\n"
6-
"POT-Creation-Date: 2025-10-24 08:05+0200\n"
6+
"POT-Creation-Date: 2025-10-29 13:04+0100\n"
77
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
88
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
99
"Language: \n"
@@ -111,7 +111,7 @@ msgstr ""
111111
msgid "Something went wrong."
112112
msgstr ""
113113

114-
#: data/resources/ui/window.ui:217 src/gui/view_model/mod.rs:233
114+
#: data/resources/ui/window.ui:217 src/gui/view_model/mod.rs:247
115115
msgid ""
116116
"Something went wrong while retrieving a credential. Please try again later "
117117
"or use a different authenticator."
@@ -187,32 +187,36 @@ msgstr ""
187187
msgid "A security key"
188188
msgstr ""
189189

190-
#: src/gui/view_model/mod.rs:65
191-
msgid "Create new credential"
190+
#: src/gui/view_model/mod.rs:70
191+
msgid "unknown application"
192192
msgstr ""
193193

194-
#: src/gui/view_model/mod.rs:66
195-
msgid "Use a credential"
194+
#: src/gui/view_model/mod.rs:75
195+
msgid "Create a new credential for %s1 via %s2"
196196
msgstr ""
197197

198-
#: src/gui/view_model/mod.rs:173
198+
#: src/gui/view_model/mod.rs:76
199+
msgid "Use a credential on %s1 via %s2"
200+
msgstr ""
201+
202+
#: src/gui/view_model/mod.rs:187
199203
msgid "Failed to select credential from device."
200204
msgstr ""
201205

202-
#: src/gui/view_model/mod.rs:227
206+
#: src/gui/view_model/mod.rs:241
203207
msgid "No matching credentials found on this authenticator."
204208
msgstr ""
205209

206-
#: src/gui/view_model/mod.rs:230
210+
#: src/gui/view_model/mod.rs:244
207211
msgid ""
208212
"No more PIN attempts allowed. Try removing your device and plugging it back "
209213
"in."
210214
msgstr ""
211215

212-
#: src/gui/view_model/mod.rs:236
216+
#: src/gui/view_model/mod.rs:250
213217
msgid "This credential is already registered on this authenticator."
214218
msgstr ""
215219

216-
#: src/gui/view_model/mod.rs:284
220+
#: src/gui/view_model/mod.rs:298
217221
msgid "Something went wrong. Try again later or use a different authenticator."
218222
msgstr ""

credentialsd-ui/po/de_DE.po

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ msgstr ""
33
"Project-Id-Version: PACKAGE VERSION\n"
44
"Report-Msgid-Bugs-To: \"https://github.com/linux-credentials/credentialsd/"
55
"issues\"\n"
6-
"POT-Creation-Date: 2025-10-24 08:05+0200\n"
6+
"POT-Creation-Date: 2025-10-29 13:04+0100\n"
77
"PO-Revision-Date: 2025-10-10 14:45+0200\n"
88
"Last-Translator: Martin Sirringhaus <martin.sirringhaus@suse.com>\n"
99
"Language: de_DE\n"
@@ -106,7 +106,7 @@ msgstr "Fertig!"
106106
msgid "Something went wrong."
107107
msgstr "Etwas ist schief gegangen."
108108

109-
#: data/resources/ui/window.ui:217 src/gui/view_model/mod.rs:233
109+
#: data/resources/ui/window.ui:217 src/gui/view_model/mod.rs:247
110110
msgid ""
111111
"Something went wrong while retrieving a credential. Please try again later "
112112
"or use a different authenticator."
@@ -188,35 +188,41 @@ msgstr "Ein NFC-Gerät"
188188
msgid "A security key"
189189
msgstr "Ein Security-Token"
190190

191-
#: src/gui/view_model/mod.rs:65
192-
msgid "Create new credential"
193-
msgstr "Neue Zugangsdaten erstellen"
191+
#: src/gui/view_model/mod.rs:70
192+
msgid "unknown application"
193+
msgstr "unbekannter Applikation"
194194

195-
#: src/gui/view_model/mod.rs:66
196-
msgid "Use a credential"
197-
msgstr "Zugangsdaten abrufen"
195+
#: src/gui/view_model/mod.rs:75
196+
#, fuzzy
197+
msgid "Create a new credential for %s1 via %s2"
198+
msgstr "Neue Zugangsdaten für %s1 via %s2 erstellen"
199+
200+
#: src/gui/view_model/mod.rs:76
201+
#, fuzzy
202+
msgid "Use a credential on %s1 via %s2"
203+
msgstr "Zugangsdaten für %s1 via %s2 abrufen"
198204

199-
#: src/gui/view_model/mod.rs:173
205+
#: src/gui/view_model/mod.rs:187
200206
msgid "Failed to select credential from device."
201207
msgstr "Zugangsdaten vom Gerät konnten nicht ausgewählt werden."
202208

203-
#: src/gui/view_model/mod.rs:227
209+
#: src/gui/view_model/mod.rs:241
204210
msgid "No matching credentials found on this authenticator."
205211
msgstr "Keine passenden Zugangsdaten auf diesem Gerät gefunden."
206212

207-
#: src/gui/view_model/mod.rs:230
213+
#: src/gui/view_model/mod.rs:244
208214
msgid ""
209215
"No more PIN attempts allowed. Try removing your device and plugging it back "
210216
"in."
211217
msgstr ""
212218
"Keine weiteren PIN-Eingaben erlaubt. Versuchen Sie ihr Gerät aus- und wieder "
213219
"einzustecken."
214220

215-
#: src/gui/view_model/mod.rs:236
221+
#: src/gui/view_model/mod.rs:250
216222
msgid "This credential is already registered on this authenticator."
217223
msgstr "Diese Zugangsdaten sind bereits auf diesem Gerät registriert."
218224

219-
#: src/gui/view_model/mod.rs:284
225+
#: src/gui/view_model/mod.rs:298
220226
msgid "Something went wrong. Try again later or use a different authenticator."
221227
msgstr ""
222228
"Es ist ein Fehler aufgetreten. Bitte versuchen Sie es später noch einmal, "

credentialsd-ui/po/en_US.po

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ msgid ""
22
msgstr ""
33
"Report-Msgid-Bugs-To: \"https://github.com/linux-credentials/credentialsd/"
44
"issues\"\n"
5-
"POT-Creation-Date: 2025-10-24 08:05+0200\n"
5+
"POT-Creation-Date: 2025-10-29 13:04+0100\n"
66
"PO-Revision-Date: 2025-10-10 14:45+0200\n"
77
"Last-Translator: Martin Sirringhaus <martin.sirringhaus@suse.com>\n"
88
"Language: en_US\n"
@@ -107,7 +107,7 @@ msgstr "Done!"
107107
msgid "Something went wrong."
108108
msgstr "Something went wrong."
109109

110-
#: data/resources/ui/window.ui:217 src/gui/view_model/mod.rs:233
110+
#: data/resources/ui/window.ui:217 src/gui/view_model/mod.rs:247
111111
msgid ""
112112
"Something went wrong while retrieving a credential. Please try again later "
113113
"or use a different authenticator."
@@ -188,35 +188,41 @@ msgstr "An NFC device"
188188
msgid "A security key"
189189
msgstr "A security key"
190190

191-
#: src/gui/view_model/mod.rs:65
192-
msgid "Create new credential"
193-
msgstr "Create new credential"
191+
#: src/gui/view_model/mod.rs:70
192+
msgid "unknown application"
193+
msgstr "unknown application"
194194

195-
#: src/gui/view_model/mod.rs:66
196-
msgid "Use a credential"
197-
msgstr "Use a credential"
195+
#: src/gui/view_model/mod.rs:75
196+
#, fuzzy
197+
msgid "Create a new credential for %s1 via %s2"
198+
msgstr "Create a new credential for %s1 via %s2"
199+
200+
#: src/gui/view_model/mod.rs:76
201+
#, fuzzy
202+
msgid "Use a credential on %s1 via %s2"
203+
msgstr "Use a credential on %s1 via %s2"
198204

199-
#: src/gui/view_model/mod.rs:173
205+
#: src/gui/view_model/mod.rs:187
200206
msgid "Failed to select credential from device."
201207
msgstr "Failed to select credential from device."
202208

203-
#: src/gui/view_model/mod.rs:227
209+
#: src/gui/view_model/mod.rs:241
204210
msgid "No matching credentials found on this authenticator."
205211
msgstr "No matching credentials found on this authenticator."
206212

207-
#: src/gui/view_model/mod.rs:230
213+
#: src/gui/view_model/mod.rs:244
208214
msgid ""
209215
"No more PIN attempts allowed. Try removing your device and plugging it back "
210216
"in."
211217
msgstr ""
212218
"No more PIN attempts allowed. Try removing your device and plugging it back "
213219
"in."
214220

215-
#: src/gui/view_model/mod.rs:236
221+
#: src/gui/view_model/mod.rs:250
216222
msgid "This credential is already registered on this authenticator."
217223
msgstr "This credential is already registered on this authenticator."
218224

219-
#: src/gui/view_model/mod.rs:284
225+
#: src/gui/view_model/mod.rs:298
220226
msgid "Something went wrong. Try again later or use a different authenticator."
221227
msgstr ""
222228
"Something went wrong. Try again later or use a different authenticator."

credentialsd-ui/src/gui/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ fn run_gui<F: FlowController + Send + Sync + 'static>(
2727
flow_controller: Arc<AsyncMutex<F>>,
2828
request: ViewRequest,
2929
) {
30-
let operation = request.operation;
3130
let (tx_update, rx_update) = async_std::channel::unbounded::<ViewUpdate>();
3231
let (tx_event, rx_event) = async_std::channel::unbounded::<ViewEvent>();
3332
let event_loop = async_std::task::spawn(async move {
33+
let request_id = request.id;
3434
let mut vm =
35-
view_model::ViewModel::new(operation, flow_controller.clone(), rx_event, tx_update);
35+
view_model::ViewModel::new(request, flow_controller.clone(), rx_event, tx_update);
3636
vm.start_event_loop().await;
3737
tracing::debug!("Finishing user request.");
3838
// If cancellation fails, that's fine.
3939
let _ = flow_controller
4040
.lock()
4141
.await
42-
.cancel_request(request.id)
42+
.cancel_request(request_id)
4343
.await;
4444
});
4545

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use async_std::{
77
channel::{Receiver, Sender},
88
sync::Mutex as AsyncMutex,
99
};
10+
use credentialsd_common::server::ViewRequest;
1011
use gettextrs::gettext;
1112
use serde::{Deserialize, Serialize};
1213
use tracing::{error, info};
@@ -29,6 +30,8 @@ where
2930
rx_event: Receiver<ViewEvent>,
3031
title: String,
3132
operation: Operation,
33+
rp_id: String,
34+
requesting_app: String,
3235

3336
// This includes devices like platform authenticator, USB, hybrid
3437
devices: Vec<Device>,
@@ -42,7 +45,7 @@ where
4245

4346
impl<F: FlowController + Send> ViewModel<F> {
4447
pub(crate) fn new(
45-
operation: Operation,
48+
request: ViewRequest,
4649
flow_controller: Arc<AsyncMutex<F>>,
4750
rx_event: Receiver<ViewEvent>,
4851
tx_update: Sender<ViewUpdate>,
@@ -51,7 +54,9 @@ impl<F: FlowController + Send> ViewModel<F> {
5154
flow_controller,
5255
rx_event,
5356
tx_update,
54-
operation,
57+
operation: request.operation,
58+
rp_id: request.rp_id,
59+
requesting_app: request.requesting_app,
5560
title: String::default(),
5661
devices: Vec::new(),
5762
selected_device: None,
@@ -61,11 +66,20 @@ impl<F: FlowController + Send> ViewModel<F> {
6166
}
6267

6368
async fn update_title(&mut self) {
64-
self.title = match self.operation {
65-
Operation::Create => gettext("Create new credential"),
66-
Operation::Get => gettext("Use a credential"),
69+
let requesting_app = if self.requesting_app.is_empty() {
70+
gettext("unknown application")
71+
} else {
72+
self.requesting_app.clone()
73+
};
74+
let mut title = match self.operation {
75+
Operation::Create => gettext("Create a new credential for %s1 via %s2"),
76+
Operation::Get => gettext("Use a credential on %s1 via %s2"),
6777
}
6878
.to_string();
79+
80+
title = title.replace("%s1", &self.rp_id);
81+
title = title.replace("%s2", &requesting_app);
82+
self.title = title;
6983
self.tx_update
7084
.send(ViewUpdate::SetTitle(self.title.to_string()))
7185
.await

credentialsd/src/credential_service/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ impl<H: HybridHandler + Debug, U: UsbHandler + Debug, UC: UiController + Debug>
101101
pub async fn init_request(
102102
&self,
103103
request: &CredentialRequest,
104+
requesting_app: Option<String>,
104105
tx: Sender<Result<CredentialResponse, CredentialServiceError>>,
105106
) {
106107
let request_id = {
@@ -126,9 +127,15 @@ impl<H: HybridHandler + Debug, U: UsbHandler + Debug, UC: UiController + Debug>
126127
CredentialRequest::CreatePublicKeyCredentialRequest(_) => Operation::Create,
127128
CredentialRequest::GetPublicKeyCredentialRequest(_) => Operation::Get,
128129
};
130+
let rp_id = match &request {
131+
CredentialRequest::CreatePublicKeyCredentialRequest(r) => r.relying_party.id.clone(),
132+
CredentialRequest::GetPublicKeyCredentialRequest(r) => r.relying_party_id.clone(),
133+
};
129134
let view_request = ViewRequest {
130135
operation,
131136
id: request_id,
137+
rp_id,
138+
requesting_app: requesting_app.unwrap_or_default(), // We can't send Options, so we send an empty string instead, if we don't know the peer
132139
};
133140

134141
let launch_ui_response = self
@@ -364,7 +371,11 @@ mod test {
364371
cred_service
365372
.lock()
366373
.await
367-
.init_request(&request, request_tx)
374+
.init_request(
375+
&request,
376+
Some(String::from("test_hybrid_sets_credential")),
377+
request_tx,
378+
)
368379
.await;
369380
user.request_hybrid_credential().await;
370381
tokio::time::timeout(Duration::from_secs(5), request_rx)

credentialsd/src/dbus/flow_control.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub async fn start_flow_control_service<
4343
Connection,
4444
Sender<(
4545
CredentialRequest,
46+
Option<String>, // Application name sending the request
4647
oneshot::Sender<Result<CredentialResponse, CredentialServiceError>>,
4748
)>,
4849
)> {
@@ -66,8 +67,11 @@ pub async fn start_flow_control_service<
6667
let (initiator_tx, mut initiator_rx) = mpsc::channel(2);
6768
tokio::spawn(async move {
6869
let svc = svc2;
69-
while let Some((msg, tx)) = initiator_rx.recv().await {
70-
svc.lock().await.init_request(&msg, tx).await;
70+
while let Some((msg, requesting_app, tx)) = initiator_rx.recv().await {
71+
svc.lock()
72+
.await
73+
.init_request(&msg, requesting_app, tx)
74+
.await;
7175
}
7276
});
7377
Ok((conn, initiator_tx))
@@ -300,24 +304,30 @@ enum SignalState {
300304
pub trait CredentialRequestController {
301305
fn request_credential(
302306
&self,
307+
requesting_app: Option<String>,
303308
request: CredentialRequest,
304309
) -> impl Future<Output = Result<CredentialResponse, WebAuthnError>> + Send;
305310
}
306311

307312
pub struct CredentialRequestControllerClient {
308313
pub initiator: Sender<(
309314
CredentialRequest,
315+
Option<String>, // Application name sending the request
310316
oneshot::Sender<Result<CredentialResponse, CredentialServiceError>>,
311317
)>,
312318
}
313319

314320
impl CredentialRequestController for CredentialRequestControllerClient {
315321
async fn request_credential(
316322
&self,
323+
requesting_app: Option<String>,
317324
request: CredentialRequest,
318325
) -> Result<CredentialResponse, WebAuthnError> {
319326
let (tx, rx) = oneshot::channel();
320-
self.initiator.send((request, tx)).await.unwrap();
327+
self.initiator
328+
.send((request, requesting_app, tx))
329+
.await
330+
.unwrap();
321331
let response = rx.await.map_err(|_| {
322332
tracing::error!("Credential response channel closed prematurely");
323333
WebAuthnError::NotAllowedError

0 commit comments

Comments
 (0)