Closed akubima closed 11 months ago
I just tried my workaround, and it works perfectly at least for attestation. So in the migration file there is this line
$table->morphs('authenticatable', 'webauthn_user_index');
that is responsible for creating these two columns in the webauthn_credentials table in the database:
authenticatable_type
and authenticatable_id
.
By default, those two columns uses varchar and bigint data types respectively and if you are using ULID instead of ID as primary in your users table eventually you will get the same error as I do which is:
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'authenticatable_id' at row 1 (Connection: mysql, SQL: insert into 'webauthn_credentials'
that error occured because ( as far as I know ) the data being inserted or updated is too long for the column's data type. So eventually I changed the authenticatable_id
column's data type to CHAR with the length of 26 (the default data type and length of ULID) and it just works at least for the attestation for the time being.
It works just fine. Thx :)
PHP & Platform
8.1.23 - Ubuntu 22.04.3 LTS WSL
Database
MySQL 8.0.33-0ubuntu0.22.04.4
Laravel version
10.10
Have you done this?
Expectation
Just installed this package did not change anything, following the documentation, attestation does not work and I need help . Thanks :)
Description
[2023-09-24 08:12:33] local.ERROR: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'authenticatable_id' at row 1 (Connection: mysql, SQL: insert into
webauthn_credentials
(authenticatable_id
,authenticatable_type
,id
,user_id
,alias
,counter
,rp_id
,origin
,transports
,aaguid
,public_key
,attestation_format
,updated_at
,created_at
) value (detail in the stack logs).I used ulid instead of id in the users table.
Reproduction
async function func_registerkey () { new WebAuthn().register().then(response => { alert('Registration successful!') }).catch(error => { console.log(error); alert('Something went wrong, try again!') }); }
Stack trace & logs
shell [2023-09-24 08:12:33] local.ERROR: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'authenticatable_id' at row 1 (Connection: mysql, SQL: insert into `webauthn_credentials` (`authenticatable_id`, `authenticatable_type`, `id`, `user_id`, `alias`, `counter`, `rp_id`, `origin`, `transports`, `aaguid`, `public_key`, `attestation_format`, `updated_at`, `created_at`) values (01hanwjtzrrn2mf7wfpa9ns6jb, App\Models\User, Ki0iUkN3NYMdIQnQxRgyGQ, c9b23794b1fa48cdb9f6b31440c28958, ?, 0, https://dev.test, https://dev.test, ?, 531126d6-e717-415c-9320-3d9aa6981239, eyJpdiI6InlaS2ZPdmxuL1cxajdPdWRYcHk2OVE9PSIsInZhbHVlIjoiU3owM3RuNy9nZCtHRi80dDlUMVFPZ0FCUFAvamZUYlJDL0ZXY0cyS0ZZS3dLdTdWTUVNUVU2dURTbXJrRlZ2Skw5RFQ5dUltanBoV1ZkWllMSUJIYXBmQTlHS2w0b3dLWCt3T1RsUXp0UXhrc0xXQkpqamZPZ3kvcFVVY0hWVVRwZTkrVU1VSjlnUzNXQ2dBR1lVT0F5ZHRLOUVMZWdoM0NJWGYwY1U5OEtWellLNkt1Yk5sRVV6WmdFM3RZVTg0MDhMVGNpR29kSUZmUk90dy94TkJNV3VNVUJWTDdPYjdTaTV5SG9mRzh2aFdXWW83S2Q5YVpDUlh3VlU2VWpyTiIsIm1hYyI6ImQ2NTcxZWY1YzQxYzA3NTIzNDY3ZWY1NmQ1ZWQ1MDUyZDQyYzZjYzg4ZDI5YjE1OWQyZTI5ODE3YjY4ZWRkM2YiLCJ0YWciOiIifQ==, none, 2023-09-24 08:12:33, 2023-09-24 08:12:33)) {"userId":"01hanwjtzrrn2mf7wfpa9ns6jb","exception":"[object] (Illuminate\\Database\\QueryException(code: 01000): SQLSTATE[01000]: Warning: 1265 Data truncated for column 'authenticatable_id' at row 1 (Connection: mysql, SQL: insert into `webauthn_credentials` (`authenticatable_id`, `authenticatable_type`, `id`, `user_id`, `alias`, `counter`, `rp_id`, `origin`, `transports`, `aaguid`, `public_key`, `attestation_format`, `updated_at`, `created_at`) values (01hanwjtzrrn2mf7wfpa9ns6jb, App\\Models\\User, Ki0iUkN3NYMdIQnQxRgyGQ, c9b23794b1fa48cdb9f6b31440c28958, ?, 0, https://dev.test, https://dev.test, ?, 531126d6-e717-415c-9320-3d9aa6981239, eyJpdiI6InlaS2ZPdmxuL1cxajdPdWRYcHk2OVE9PSIsInZhbHVlIjoiU3owM3RuNy9nZCtHRi80dDlUMVFPZ0FCUFAvamZUYlJDL0ZXY0cyS0ZZS3dLdTdWTUVNUVU2dURTbXJrRlZ2Skw5RFQ5dUltanBoV1ZkWllMSUJIYXBmQTlHS2w0b3dLWCt3T1RsUXp0UXhrc0xXQkpqamZPZ3kvcFVVY0hWVVRwZTkrVU1VSjlnUzNXQ2dBR1lVT0F5ZHRLOUVMZWdoM0NJWGYwY1U5OEtWellLNkt1Yk5sRVV6WmdFM3RZVTg0MDhMVGNpR29kSUZmUk90dy94TkJNV3VNVUJWTDdPYjdTaTV5SG9mRzh2aFdXWW83S2Q5YVpDUlh3VlU2VWpyTiIsIm1hYyI6ImQ2NTcxZWY1YzQxYzA3NTIzNDY3ZWY1NmQ1ZWQ1MDUyZDQyYzZjYzg4ZDI5YjE1OWQyZTI5ODE3YjY4ZWRkM2YiLCJ0YWciOiIifQ==, none, 2023-09-24 08:12:33, 2023-09-24 08:12:33)) at /var/www/projects/evangeline/vendor/laravel/framework/src/Illuminate/Database/Connection.php:801) [stacktrace] #0 /var/www/projects/evangeline/vendor/laravel/framework/src/Illuminate/Database/Connection.php(755): Illuminate\\Database\\Connection->runQueryCallback() #1 /var/www/projects/evangeline/vendor/laravel/framework/src/Illuminate/Database/Connection.php(581): Illuminate\\Database\\Connection->run() #2 /var/www/projects/evangeline/vendor/laravel/framework/src/Illuminate/Database/Connection.php(533): Illuminate\\Database\\Connection->statement() #3 /var/www/projects/evangeline/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3338): Illuminate\\Database\\Connection->insert() #4 /var/www/projects/evangeline/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1968): Illuminate\\Database\\Query\\Builder->insert() #5 /var/www/projects/evangeline/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1309): Illuminate\\Database\\Eloquent\\Builder->__call() #6 /var/www/projects/evangeline/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1137): Illuminate\\Database\\Eloquent\\Model->performInsert() #7 /var/www/projects/evangeline/vendor/laragear/webauthn/src/Http/Requests/AttestedRequest.php(83): Illuminate\\Database\\Eloquent\\Model->sav