teamhanko / hanko

Authentication and user management system optimized for passkeys
https://hanko.io
Other
5.6k stars 790 forks source link

fix: don't override error before return #1447

Closed FreddyDevelop closed 2 months ago

FreddyDevelop commented 2 months ago

Description

When registering a webauthn credential fails the internal error is overridden and therefore not returned.

Implementation

The error is overridden by an auditLogger error, now the auditLog error is now assigned to a new variable instead.

Tests

Create a webauthn config where origins is not set correct (e.g. "https://example.com") and try to register a new webauthn credential. Before the fix the error on the logs on show code=400, message=failed to validate attestation. With the fix it should include the internal error code=400, message=failed to validate attestation, internal=Error validating origin