0
我有一個使用phpCAS單點登錄驗證用戶的Laravel 4應用程序。但是,我無法確定如何鎖定任何未經授權的用戶訪問我的任何應用程序URL。對於這種情況,有許多用戶可以在頁面中傳遞phpCAS日誌,但如果他們沒有管理員權限,應同時拒絕訪問我的應用程序(除訪問拒絕頁面外)。如何鎖定應用程序中的未授權用戶?
如何禁止這些用戶在顯示我的拒絕訪問頁面時訪問我的應用的URL?
routes.php文件:
Route::get('/adminHome/{USER_ID}', array('as' => 'home', 'uses' => '[email protected]'));
Route::get('/adminHome/create/{USER_ID}', '[email protected]');
Route::get('/adminHome/{adminID}/delete/{USER_ID}', '[email protected]');
Route::post('/adminHome/store/{USER_ID}', '[email protected]');
Route::get('/adminHome', '[email protected]__construct');
Route::get('/accessDenied', array('as' => 'accessDenied', 'uses' => '[email protected]'));
管理控制器:
public function __construct()
{
App::make('CAS');
$ID = $_SESSION['phpCAS']['attributes']['UDC_IDENTIFIER'];
$admin = App::make('AdminServices');
$isValidAdmin = $admin->isAdmin($ID);
//check DB to see if user has admin access rights
if ($isValidAdmin && $isValidAdmin->ADMIN == "yes")
{
return Redirect::route('home', $ID);
}
else
{
return Redirect::route('accessDenied');
}
}
public function accessDenied()
{
return View::make('users/accessdenied');
}
的意見/用戶存取遭拒/:
<div class="alert alert-danger" role="alert" align="center"><strong>Access Denied. </strong>You do not have permission to access this page. Please notify the system administrator to obtain access.</div>
看一看的文檔[過濾器](http://laravel.com/docs/routing#route-filters) – 2014-08-27 15:21:04
你的代碼似乎已經解決了你的問題 – worldask 2014-08-27 15:21:54
@MattBurrow,那正是我需要的。現在使用filters.php工作 – Burntspaghetti 2014-08-27 19:59:22