Skip to content

Client name validator uses hardcoded length #1299

Closed
@particleflux

Description

@particleflux
  • Passport Version: 7.5.1 (but seems to be still present in current master)
  • Laravel Version: 5.8.7 (though it should be still present with v7)
  • PHP Version: 7.2.29
  • Database Driver & Version: MySql 5.7

Description:

On creation or updating of a client via Laravel\Passport\Http\Controllers\ClientController, the name parameter is validated with a hardcoded maximum length of 255. This length is the default for Blueprint, but it can be customized via Schema::defaultStringLength().

Having a customized length there might lead to crashes due to database errors, in case the customized length is smaller than 255.

Customizing that length seems to be quite common, due to index size constraints in combination with utf8mb4_unicode_ci collation. See https://laravel.com/docs/7.x/migrations#creating-indexes in paragraph Index Lengths & MySQL / MariaDB.

Steps To Reproduce:

  1. Customize the defaultStringLength in AppServiceProvider, for example like this:
    Schema::defaultStringLength(191);
  2. Run initial passport migrations
  3. Column size in DB will not match validation size
  4. Try to create a new or update an existing client via ClientController, and observe the application crashing on a database error

String data, right truncated: 1406 Data too long for column 'name' at row 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions