forked from rap2hpoutre/laravel-log-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic Auth For Production rap2hpoutre#294
- Loading branch information
1 parent
d09e6b5
commit e911ac4
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Rap2hpoutre\LaravelLogViewer; | ||
|
||
use Closure; | ||
|
||
use Config; | ||
|
||
class LogViewerBasicAuthMiddleware | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \Closure $next | ||
* @return mixed | ||
*/ | ||
public function handle($request, Closure $next) | ||
{ | ||
$username = Config::get('logviewer.username'); | ||
$password = Config::get('logviewer.password'); | ||
|
||
$givenUsername = $request->getUser(); | ||
$givenPassword = $request->getPassword(); | ||
|
||
if ($givenUsername !== $username || $givenPassword !== $password) { | ||
return response('Unauthorized.', 401, ['WWW-Authenticate' => 'Basic']); | ||
} | ||
|
||
return $next($request); | ||
} | ||
} |