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

Feature Request: Support String-based Client ID #469

edsamonte opened this Issue Aug 12, 2017 · 4 comments


None yet
5 participants

edsamonte commented Aug 12, 2017

Just a feature request to support string-based Client ID. IMHO, having an auto-incremented Client ID is pretty plain and might lead to security vulnerability (i.e. brute-force attack on implicit grants).

I would suggest to have something like this on the Client Model:

        static::creating(function (Client $client) {
            if (!$client->id) {
                $client->id = Passport::generateClientId($client->name);

And have something like this on the Passport helper:

     * Generates Client ID
     * @param $clientName
     * @return string
    public static function generateClientId($clientName)
        if (static::$clientIdGenerator instanceof \Closure) {
            return (string)static::$clientIdGenerator->call(new static, $clientName);

        $length = config('passport.id_length', 12);
        $max = pow(10, $length) - 1;
        if ($max > PHP_INT_MAX) {
            $max = PHP_INT_MAX;
        $out = random_int(0, $max);
        return str_pad($out, $length, '0', STR_PAD_LEFT);

     * Set the Client ID Generator function. The function should receive a Client Name
     * and return an ID in string format.
     * @param \Closure $generator
    public static function setClientIdGenerator(\Closure $generator)
        static::$clientIdGenerator = $generator;

I'd be happy to create a PR request if this one is planned.


This comment has been minimized.

emiliopedrollo commented Aug 12, 2017

There has been some effort before in using uuid as client_id. Maybe the developers should consider that.


This comment has been minimized.

cweiske commented Feb 8, 2018

Duplicate of #14.


This comment has been minimized.

mloberg commented Aug 17, 2018

You can achieve UUIDs by updating the migration and using model listeners.


This comment has been minimized.


driesvints commented Oct 16, 2018

Duplicate of #14.

@driesvints driesvints closed this Oct 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment