# Deny all controllers an allow only two methods from a controller

**URL:** <https://discourse.cakephp.org/t/deny-all-controllers-an-allow-only-two-methods-from-a-controller/3388>\
**Category:** Need Help\
**Created:** [October 24, 2017, 3:41pm UTC](https://discourse.cakephp.org/t/deny-all-controllers-an-allow-only-two-methods-from-a-controller/3388 "2017-10-24T15:41:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![angelorigo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/angelorigo/32/193_2.png) [@angelorigo](https://discourse.cakephp.org/u/angelorigo)\
**Post date:** [October 24, 2017, 3:41pm UTC](https://discourse.cakephp.org/t/deny-all-controllers-an-allow-only-two-methods-from-a-controller/3388/1 "2017-10-24T15:41:47Z")

</div>

In a CakePhp 2.5 application i have a rule, saying that blocked users can not login, at AppController (‘scope’ =\> array(‘User.access’ =\> 1),).

How can i enable access to only two methods for the blocked users ?  
Make sure they can not access all the others methods.  
Make sure they can not access all the others controllers.

In appController i declare in the scope property, there i say that User.access having 1 can login, so blocked users can not login.

I already do remove scope property :

```
//'scope' => array('User.access' => 1),

```

I try at appController into the beforeFilter using `$this->Auth->deny();`  
and after  
`$this->Auth->allow(array('myAllowedMethod'))`  
but the users still access all methods.

The original access control uses permissions.ini file

AppController :

```
public $components = array(
        'Auth' => array('authenticate' => array(
                'Form' => array(
                    'userModel' => 'User',
                    'scope' => array('User.access' => 1),

```

Is there a way to filter blocked users ( they have User.access = 0 ) and allow only two needed methods ?

---

<div class="post-metadata">

**Author:** ![xaphalanx](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/xaphalanx/32/575_2.png) [@xaphalanx](https://discourse.cakephp.org/u/xaphalanx)\
**Post date:** [October 27, 2017, 6:34pm UTC](https://discourse.cakephp.org/t/deny-all-controllers-an-allow-only-two-methods-from-a-controller/3388/2 "2017-10-27T18:34:31Z")

</div>

All are denied by default when you configure Auth.

Remove the deny line and just allow in your beforeFilter:

`php $this->Auth->allow(array('yourMethod1', 'yourMethod2'));`

---

<div class="post-metadata">

**Author:** ![angelorigo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/angelorigo/32/193_2.png) [@angelorigo](https://discourse.cakephp.org/u/angelorigo)\
**Post date:** [October 27, 2017, 6:55pm UTC](https://discourse.cakephp.org/t/deny-all-controllers-an-allow-only-two-methods-from-a-controller/3388/3 "2017-10-27T18:55:01Z")

</div>

Can i say also wich controller would allowed. Because i need to do it in AppController
