-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The client id should not be an auto increment integer. #576
Comments
I think UUID should be added as an additional feature. Simply by running a command php artisan passport:uuid activate would now perform making client id as UUID. This way passport would be kept simple and whoever want to use this functionality can easily inherit. |
Mind-boggling that this STILL hasn't been done. Its a MAJOR breaking change if its really to replace Lucade's server. |
The discussion is going on from Passport 0.1 version. I was expecting it to see it would be added in v2. But still, it is pending. As per Taylor's comment, I remember he wants to keep Passport simple. But this is been demanded by a lot of people. That's why I said it should be added as an addition or optional feature. I'll submit a PR if @taylorotwell accept it as an optional command to implement it. |
It's even worse. Quoting the email I sent to Taylor at the end of October without hearing back:
|
Hi, What is the current status of using UUID for client ID? |
@josephxanderson, your solution seems not to work correctly. From my understanding, although the value saved into the database is a UUID, but the Client model will return a wrong value for its ID. This is due to the data type of primary key is not overridden in the model so it is always be treated as an integer. Correct me if I'm wrong. |
@josephxanderson in my case, the table data type is correct, and there's no error thrown. But do you notice that the I did run
|
@josephxanderson me too , im having the same issue when changing all the client_id in migrations to string data type. I hope someone could help with this issue. |
@Modelizer 's idea would work perfectly here as by default, passport will still work with integers. This will avoid any breaking changes. Plenty of valid points have repeatedly been made about how non-integer client IDs are preferred with the main one being That said, you should have other concerns if your client secret managed to get leaked. |
I create a simple package for this, it convert client id in all the table to Uuid. |
Hey guys, I found a solution for this. We can register Sample for my client class. namespace App;
use Laravel\Passport\Client as BaseClient;
class Client extends BaseClient
{
public function getIncrementing()
{
return false;
}
public function boot()
{
parent::boot();
static::creating(function (Model $model) {
if (!isset($model->attributes[$model->getKeyName()])) {
$model->attributes[$model->getKeyName()] = Str::orderedUuid()->toString();
}
});
}
} I use a trait to generate the UUID, but I think the above code should work the same way. NOTE: You need to use |
You can also update the migrations and use model listeners. https://mlo.io/blog/2018/08/17/laravel-passport-uuid/ |
Closing this as a duplicate of #14. Please continue discussion there. Thanks. |
For sure that was already discussed nevertheless client ids should not be an auto increment integer for several reasons:
Please, share your thoughts.
The text was updated successfully, but these errors were encountered: