Skip to content

Commit

Permalink
Merge pull request #25 from langleyfoxall/fix-logs-issue
Browse files Browse the repository at this point in the history
Ensure logs endpoint relies on config rather than the environment
  • Loading branch information
DivineOmega authored Apr 17, 2019
2 parents aaa16b6 + eecf4f2 commit 1232eb5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
27 changes: 27 additions & 0 deletions app/Providers/LogViewerRouteProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Rap2hpoutre\LaravelLogViewer\LogViewerController;
use Route;

class LogViewerRouteProvider extends ServiceProvider
{
/**
* Register the log viewer route, if the appropriate access credentials have been set in the app configuration.
*
* @return void
*/
public function boot()
{
['username' => $username, 'password' => $password] = config('laravel-route-restrictor.logs');

if (empty($username) || empty($password)) {
return;
}

Route::get('/logs', [LogViewerController::class, 'index'])
->middleware("routeRestrictor:$username,$password");
}
}
1 change: 1 addition & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\LogViewerRouteProvider::class,

],

Expand Down
7 changes: 6 additions & 1 deletion config/laravel-route-restrictor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
'global' => [
'username' => env('ROUTE_RESTRICTOR_GLOBAL_USERNAME', null),
'password' => env('ROUTE_RESTRICTOR_GLOBAL_PASSWORD', null)
]
],

'logs' => [
'username' => env('LOGS_USERNAME'),
'password' => env('LOGS_PASSWORD')
],

];
5 changes: 0 additions & 5 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
|
*/


Route::get('/', function () {
return view('welcome');
});

Route::group(['middleware' => 'routeRestrictor:'.env('LOGS_USERNAME').','.env('LOGS_PASSWORD')], function () {
Route::get('/logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

0 comments on commit 1232eb5

Please sign in to comment.