Repository navigation
Conversation
|
Also tested the full flow with a real phone. I started a create request with Bluetooth off, turned Bluetooth on about 8 s in, and the QR code appeared within the same second. I scanned it with a phone and approved; the phone went through ProximityCheck → Connecting → Connected → PresenceRequired, and |
|
I think I'd like ultimately like to resolve this at the libwebauthn layer, where libwebauthn gives an API to wait for a suitable bluetooth adapter and starts a request, rather than that being credentialsd's responsibility. However, I think this PR is good for dicsussing how we might consume that API though on the UI side. As far as the backend API, @msirringhaus and I have been discussing this a bit. I'm leaning toward having a |
|
Thanks, agreed: waiting for a usable adapter belongs in libwebauthn. The polling of BlueZ here is a stopgap until it has an API for that. Some notes from wiring up the UI side, in case they help with the API:
How would you like to handle this PR in the meantime? I can keep it open as the UI-side piece and switch it to the |
1 similar comment
|
Thanks, agreed: waiting for a usable adapter belongs in libwebauthn. The polling of BlueZ here is a stopgap until it has an API for that. Some notes from wiring up the UI side, in case they help with the API:
How would you like to handle this PR in the meantime? I can keep it open as the UI-side piece and switch it to the |
libwebauthn reports Bluetooth as available whenever an adapter exists, even while it is powered off, and the transports were only detected once at the start of a request. So with Bluetooth off, the QR code option was offered but could not work, and turning Bluetooth on did not help. - Ask BlueZ whether an adapter is powered on, and only offer hybrid then. The check gives up after 1 s and doesn't start BlueZ if it isn't running. - If hybrid was not offered when discovery starts, check BlueZ every 2 s while it has an adapter that is turned off. Once one is turned on, add hybrid to the request's transports, send the UI the new list (new NotifyTransportsChanged UI control method) and start hybrid discovery. This happens at most once per request. - The UI keeps transports that gave up earlier in the request hidden when it gets a new list. Closes linux-credentials#206
4acc1f3 to
6e08d5c
Compare
Closes #206 (first part: updating the transports offered; prompting the user to turn Bluetooth on is left for a follow-up).
Rebased on main, and reworked for main's transport model: transports are now detected once in
init_request, stored in the request context, sent to the UI inCreateSession, andstart_discoverystarts exactly those.Problem
libwebauthn's
available_transports()reports Ble/Hybrid whenever a Bluetooth adapter exists. BlueZ keeps the adapter while Bluetooth is turned off, so the QR code option was offered even though it couldn't work. And the transports were only detected once, so turning Bluetooth on mid-request didn't help.Changes
credential_service/bluetooth.rs: asks BlueZ (GetManagedObjectson the system bus) whether anyorg.bluez.Adapter1isPowered.init_requestonly offers hybrid then. The call gives up after 1 s, so a stuck bluetoothd can't hold up a request, and setsNO_AUTO_START, so it never starts BlueZ.start_discovery: if hybrid wasn't offered, a watcher asks BlueZ every 2 s while it has an adapter that is turned off. It stops if BlueZ isn't running or has no adapter, and when the request's cancellation token fires. Once an adapter is powered on,add_hybridaddsHybridQrto the request's transports (checking the request ID, so a late start can't attach to a different request), the UI gets the new list, and hybrid discovery starts.NotifyTransportsChanged(session_handle, as transports, a{sv} options)/BackgroundEvent::TransportsChanged: the full new list, in the same form asCreateSession's transports. Listed in the changelog under UI Controller API.TransportUnavailable) hidden, since the daemon still lists them.Limitations
HybridStartedsets the QR prompt even if the user is on another transport's page. That's existing UI behaviour, but it can now happen mid-request.Open questions
PropertiesChanged/InterfacesAddedfrom BlueZ, to keep this small. It only runs while a request waits for an adapter that is turned off. Happy to switch to signals if you prefer.Testing
add_hybrid, and the UI applying a new list while keeping stopped transports hidden.cargo test --bins(daemon 70, UI 7),cargo clippy --all-targets -D warnings,cargo fmt --check.