mirror of
				https://github.com/BookStackApp/BookStack.git
				synced 2025-11-04 13:31:45 +03:00 
			
		
		
		
	- Included tests to cover for LDAP and SAML - Updated wording for external auth id option. - Updated 'assertPermissionError' test case to be usable in BrowserKitTests
		
			
				
	
	
		
			28 lines
		
	
	
		
			604 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			604 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace BookStack\Http\Middleware;
 | 
						|
 | 
						|
use Closure;
 | 
						|
 | 
						|
class CheckGuard
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Handle an incoming request.
 | 
						|
     *
 | 
						|
     * @param  \Illuminate\Http\Request  $request
 | 
						|
     * @param  \Closure  $next
 | 
						|
     * @param string $allowedGuards
 | 
						|
     * @return mixed
 | 
						|
     */
 | 
						|
    public function handle($request, Closure $next, ...$allowedGuards)
 | 
						|
    {
 | 
						|
        $activeGuard = config('auth.method');
 | 
						|
        if (!in_array($activeGuard, $allowedGuards)) {
 | 
						|
            session()->flash('error', trans('errors.permission'));
 | 
						|
            return redirect('/');
 | 
						|
        }
 | 
						|
 | 
						|
        return $next($request);
 | 
						|
    }
 | 
						|
}
 |