Return WebAuthn credential record in create response#7145
Conversation
|
Great job! No new security vulnerabilities introduced in this pull request |
|
Claude finished @iinuwa's task in 4m 35s —— View job Code Review: Return WebAuthn credential record in create response
Overall: This is a clean, well-scoped change. The approach of changing the return type from Findings1. Good: Null safety improvementsThe PR removes the 2. Good: New null check on
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7145 +/- ##
==========================================
+ Coverage 56.66% 56.69% +0.03%
==========================================
Files 2024 2025 +1
Lines 88602 88644 +42
Branches 7905 7906 +1
==========================================
+ Hits 50205 50257 +52
+ Misses 36571 36560 -11
- Partials 1826 1827 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ike-kottlowski
left a comment
There was a problem hiding this comment.
Changes look good.
You mention in the description that this should be fine as long as a client doesn't assert null. Can you follow up on that to ensure this change won't cause failures on the web client?
Sorry, I should have been clear: I was referring to third-party clients there. The web client does not assert an empty body, just an HTTP success code: https://github.com/bitwarden/clients/blob/main/apps/web/src/app/auth/core/services/webauthn-login/webauthn-login-admin-api.service.ts#L43-L46. I have also confirmed locally that the changes work with the production client. |
* Return WebAuthn credential record in create response * Make CreateWebAuthnLoginCredentialCommand null-safe




🎟️ Tracking
PM-33110
📔 Objective
Background
For the device auth key feature, we need to be able to delete a specific WebAuthn credential record from a mobile device when the user disables the setting or logs out. Right now, we cannot do that because the only ID that the caller has is the credential ID, which is generated by the caller. The delete endpoint only takes record IDs, which is distinct from the FIDO2 credential ID. The record ID is not returned from the create endpoint, so the caller cannot use it.
Currently, the delete method requires you to fetch all the credentials, and then the user can select which one they want to delete based on the name of the credential record, and pass the record ID to the delete endpoint. This works in the web vault, but not in the case of device auth keys on mobile, where it doesn’t make sense to list all the keys.
I would like to be able to delete a specific record by ID directly instead.
Changes
This PR modifies the WebAuthn create credential endpoint response to return the created object that is saved in the database, which includes the GUID of the generated record. This allows the mobile device to save the ID locally and use it to delete the credential later.
This is backwards compatible, because the response was empty before (unless a client is asserting the empty response). (For the mobile client implementation, I recommend that we require the model so that we can avoid having an optional field stored on devices forever, so the feature will be unavailable on clients connecting to older servers.)