Is there a way to overide the passport route middleware with your own auth guard?
In my boot method of the AuthServiceProvider I can do the following but it simply merges the middleware with the defaults (https://github.com/laravel/passport/blob/master/src/Passport.php) :
public function boot()
{
$this->registerPolicies();
Passport::routes(null, ['middleware' => 'auth:recruiters']);
}
For example the above gives me the following middleware applied to the routes:
GET|HEAD | oauth/authorize | | Laravel\Passport\Http\Controllers\AuthorizationController@authorize | auth:recruiters,web,auth
I want to completely remove the auth middleware where it is applied to any passport routes and replace with auth:recruiter or any other guard.
In my config/auth.php I have my guards set up as follows - note the provider is the users table so the only thing I want to implement is to change the deafult auth in the passport routes by specifying a guard:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
'recruiter' => [
'driver' => 'session',
'provider' => 'users',
],
],
Do I need to write my own passport routes to achieve this and if so do i just stick them in the routes.php file and remove the Passport::routes() from the boot method?
Whats the callback option on the Passport::routes() method, can I use that perhaps to overide the existing routes?
public static function routes($callback = null, array $options = [])
{
$callback = $callback ?: function ($router) {
$router->all();
};
$defaultOptions = [
'prefix' => 'oauth',
'namespace' => '\Laravel\Passport\Http\Controllers',
];
$options = array_merge($defaultOptions, $options);
Route::group($options, function ($router) use ($callback) {
$callback(new RouteRegistrar($router));
});
}
Some guidance would be appreciated along with some code snippet for support.