From c22d5dc209a2f39553ad9f9ac2588a4e3355df47 Mon Sep 17 00:00:00 2001 From: Chris Bellas Date: Thu, 1 Jul 2021 10:27:19 +0300 Subject: [PATCH] Enable/disable authentication middleware dynamically --- api/.env.example | 1 + api/routes/api.php | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/.env.example b/api/.env.example index 3d37b71..cb07ed8 100644 --- a/api/.env.example +++ b/api/.env.example @@ -55,3 +55,4 @@ OD_GRAFANA_PARAMS=/d/qDDyJZ6Wz/od?orgId=1 MLTD_GRAFANA_PARAMS=/d/dtCrgk6Wk/mltd?orgId=1 CEPTD_KIBANA_PARAMS="/app/kibana#/dashboard/Suricata?_g=(refreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3Anow-15m%2Cto%3Anow))" +AUTH_ENABLED=false diff --git a/api/routes/api.php b/api/routes/api.php index c2684b8..3ca7938 100644 --- a/api/routes/api.php +++ b/api/routes/api.php @@ -13,7 +13,9 @@ use Illuminate\Support\Facades\Route; | */ -//Route::group(['middleware' => 'auth:api'], function () { +$parameters = env('AUTH_ENABLED') ? ['middleware' => 'auth:api'] : []; + +Route::group($parameters, function () { Route::get('config', 'ConfigController@index'); Route::get('capec', 'CapecController@index'); Route::group(['prefix' => 'v1'], function () { @@ -35,7 +37,7 @@ use Illuminate\Support\Facades\Route; Route::get('events/group','V1\Components\MltdController@group'); Route::get('events/last','V1\Components\MltdController@last'); //should be last since matches to anything */* - Route::get('{train_id}/{top}', 'V1\Components\MltdController@train'); + Route::get('{train_id}/{top}', 'V1\Components\MltdController@train'); }); Route::group(['prefix' => 'od'], function () { Route::get('start', 'V1\Components\OdController@start'); @@ -47,5 +49,4 @@ use Illuminate\Support\Facades\Route; Route::get('events/last','V1\Components\OdController@last'); }); }); - -//}); \ No newline at end of file +}); -- 2.2.2