title: Best way to check permissions with sentry 2 at Laravel
body: <p>Im developing a basic aplication core, first im working with user/groups and &amp; permissions access.</p>
  
  <p>I choose Sentry 2 to work, and i want to limit the access to my.domain/admin to a users or groups that have admin permissions.</p>
  
  <p>Im developing a filter to check if the user is admin and if hasAccess to a specific action, like users.index, or users.custom_fuction.</p>
  
  <p>In my routes i have:</p>
  
  <pre><code>/**
  * ADMIN ROUTES
  */
  Route::group(array('before' =&gt; 'sentry'), function() {
      Route::group(array('before' =&gt; 'admin'), function() {
  
          Route::group(array('prefix' =&gt; 'admin'), function()
          {
  
              Route::get('/', function()
              {
                  return View::make('admin');
              });
  
              Route::resource('groups', 'GroupController',
                  array('except' =&gt; array('show')));
  
              Route::resource('users', 'UserController',
                  array('except' =&gt; array('show')));
  
              Route::get('users/{id}/groups', 'UserController@groups');
              Route::post('users/{id}/groups', 'UserController@store_groups');
  
              Route::get('{table}/{id}/permissions',
                 'PermissionController@manage_entity');
              Route::post('{table}/{id}/permissions',
                 'PermissionController@update_permissions');
          });
      });
  });
  </code></pre>
  
  <p>The sentry filter only checks if is loged and rediret to login page, the admin filter is:</p>
  
  <pre><code>/*
   * Sentry admin &amp; hasAccess filter
   */
  Route::filter('admin', function()
  {
      $user = Sentry::getUser();
  
      if (!$user-&gt;hasAccess('admin')) return Redirect::to('/');
  
      // Ask if user hasAccess to specific action
      var_dump(Route::getCurrentRoute()-&gt;getPath());
      var_dump(Route::getCurrentRoute()-&gt;getAction());
  });
  </code></pre>
  
  <p>I have to make another check with the actual route, in the getAction array there are a</p>
  
  <pre><code>'as' =&gt; string 'admin.users.index' (length=17)
  </code></pre>
  
  <p>I can use that for Route::resource i define but, how i did for other functions like groups or permissions.</p>
  
  <p>Maybe there is a better way to handle that, but i dont know it.</p>
  
  <p>Thanks in advice.</p>