Last active
December 24, 2015 22:19
-
-
Save dkesberg/6872094 to your computer and use it in GitHub Desktop.
Require auth basic on HTTP requests or functions
This file contains hidden or 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
// router.php | |
Route::group(array('prefix' => 'api/v1'), function() | |
{ | |
Route::resource('tweets', 'ApiController'); | |
} | |
// RestController | |
class RestController extends BaseController { | |
public function __construct() | |
{ | |
// auth on request type | |
$this->beforeFilter('auth.basic', array('on' => array('post','put','patch','delete'))); | |
// auth on function | |
$this->beforeFilter('auth.basic', array('only' => array('create','store','edit', 'update', 'destroy'))); | |
// auth except on function | |
$this->beforeFilter('auth.basic', array('except' => array('index','show'))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment