0
votes

At my organization we have an OpenLDAP server which stores user's password. We also have another MySQL database which stores user's information. Therefore when we want to authenticate user we authenticate with LDAP and then retrieve user's information from MySQL database.

Things look good so far with Laravel authentication which separates guards and providers. In our case we would use LDAP authentication as guard and eloquent provider to retrieve data from MySQL.

Now we want to implement an API authentication using Laravel Passport, but all tutorials that I have seen all use authenticatable users. But we cannot do that because passwords are not in the database and users cannot be authenticatable.

Could anyone suggest how to use Laravel Passport in this case?

1
You can use Authenticatable and overload the method that recovers the password getAuthPassword()N69S
@N69S thanks, any resources on how to overload Authenticatable?Anurat Chapanond

1 Answers

0
votes

You can overload the getAuthPassword() in your model.

class User extends Authenticatable implements CanResetPassword
{
    use SoftDeletes, Notifiable, CanResetPasswordTrait;

    public function getAuthPassword()
    {
        return '<password from another place using user ID:'.$this->id.'>';
    }