Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Commit

Permalink
fix authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Verstraeten committed Jun 19, 2017
1 parent 46944e8 commit bad5029
Show file tree
Hide file tree
Showing 17 changed files with 345 additions and 37 deletions.
3 changes: 2 additions & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\LoadUsersFromConfig::class,
];

/**
Expand All @@ -28,7 +29,6 @@ class Kernel extends HttpKernel
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
//\App\Http\Middleware\SimpleAuth::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
Expand All @@ -51,6 +51,7 @@ class Kernel extends HttpKernel
*/
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.simple' => \App\Http\Middleware\SimpleAuth::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
Expand Down
26 changes: 26 additions & 0 deletions app/Http/Middleware/LoadUsersFromConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Http\Middleware;

use Config;
use Closure;
use Illuminate\Support\Facades\Auth;

class LoadUsersFromConfig
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
$users = Config::get('kerberos.users');
Auth::getProvider()->setUsers($users);

return $next($request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Middleware;

use Config;
use Closure;
use Illuminate\Support\Facades\Auth;

Expand All @@ -18,6 +19,7 @@ class SimpleAuth
public function handle($request, Closure $next, $guard = null)
{
$loggedIn = Auth::guard($guard)->check();

if(!$loggedIn)
{
if($request->ajax())
Expand Down
2 changes: 0 additions & 2 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ class AuthServiceProvider extends ServiceProvider
public function boot()
{
$this->registerPolicies();

//
}
}
Loading

0 comments on commit bad5029

Please sign in to comment.