discourse/spec/lib/discourse_webauthn
Keegan George 0626ec1a29
FIX: passkey registration failing when extension data included (#38266)
**Currently, passkey registration has two bugs:**
1. Registration fails with an HTTP 500 for authenticators that include
extension data (i.e. `hmac-secret` in their attestation response)
because we slice all bytes after the credential ID the public key.
2. Registration fails with `NotAllowedError` on some hardware keys (i.e.
Solo 2) because `pubKeyCredParams` includes invalid HMAC symmetric
algorithms from the `COSE` gem, which strict authenticator firmware
rejects.

**This fix:**
1. Uses `CBOR::Unpacker` streaming decode to read exactly one `CBOR`
object from the byte stream, stopping before any trailing extension
data. Also adds `COSE::MalformedKeyError` to the rescue block so future
failures return a proper error response.
2. Replaces the blanket `COSE::Algorithm.registered_algorithm_ids` with
an explicit list of asymmetric signature algorithms valid for
`WebAuthn`.

Meta bug report:
https://meta.discourse.org/t/cant-set-up-passkey-on-any-discourse/397642/
2026-03-05 09:51:04 -08:00
..
authentication_service_spec.rb DEV: Rename SecureSession to ServerSession 2025-09-18 16:31:03 +02:00
challenge_generator_spec.rb DEV: Rename SecureSession to ServerSession 2025-09-18 16:31:03 +02:00
discourse_webauthn_spec.rb DEV: Rename SecureSession to ServerSession 2025-09-18 16:31:03 +02:00
registration_service_spec.rb FIX: passkey registration failing when extension data included (#38266) 2026-03-05 09:51:04 -08:00