Apply always authenticate to the api routes

This commit is contained in:
Nico Stapelbroek
2018-01-27 23:04:25 +01:00
parent b866ffea4e
commit 11f8e57259

View File

@@ -167,6 +167,11 @@ class RouteServiceProvider extends ServiceProvider
Timezone::class,
];
$applyAlwaysAuthenticate = $this->app['config']->get('setting.always_authenticate', false);
if ($applyAlwaysAuthenticate && !$this->isWhiteListedAuthRoute($routes)) {
$middleware[] = 'auth.api:true';
}
$router->group(['middleware' => $middleware], function (Router $router) use ($routes) {
$routes->map($router);
});