# How can I stop throwing "403, 'Forbidden'" by apigility for non-rest/non-rpc controllers?

**URL:** <https://discourse.laminas.dev/t/how-can-i-stop-throwing-403-forbidden-by-apigility-for-non-rest-non-rpc-controllers/1180>\
**Category:** API Tools\
**Created:** [September 6, 2019, 2:41pm UTC](https://discourse.laminas.dev/t/how-can-i-stop-throwing-403-forbidden-by-apigility-for-non-rest-non-rpc-controllers/1180 "2019-09-06T14:41:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![testuser](https://avatars.discourse-cdn.com/v4/letter/t/e495f1/32.png) [@testuser](https://discourse.laminas.dev/u/testuser)\
**Post date:** [September 6, 2019, 2:41pm UTC](https://discourse.laminas.dev/t/how-can-i-stop-throwing-403-forbidden-by-apigility-for-non-rest-non-rpc-controllers/1180/1 "2019-09-06T14:41:54Z")

</div>

At this line [https://github.com/zfcampus/zf-apigility/blob/master/src/MvcAuth/UnauthorizedListener.php#L27](https://github.com/zfcampus/zf-apigility/blob/master/src/MvcAuth/UnauthorizedListener.php#L27) of code throw “403, ‘Forbidden’” for non-rest/non-rpc controllers but it was planed to be applicable only for rest/rpc controllers.

At this line [https://github.com/zfcampus/zf-mvc-auth/blob/master/src/Authentication/DefaultAuthenticationListener.php#L173](https://github.com/zfcampus/zf-mvc-auth/blob/master/src/Authentication/DefaultAuthenticationListener.php#L173) of code is set ‘ZF\MvcAuth\Identity’ which is getted only in RestController here [https://github.com/zfcampus/zf-rest/blob/master/src/RestController.php#L855](https://github.com/zfcampus/zf-rest/blob/master/src/RestController.php#L855) .

I am trying to add authentication adapter as I’ve describe here [How to add authentication adapter to controller?](https://discourse.zendframework.com/t/how-to-add-authentication-adapter-to-controller/1179) .

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [September 6, 2019, 3:05pm UTC](https://discourse.laminas.dev/t/how-can-i-stop-throwing-403-forbidden-by-apigility-for-non-rest-non-rpc-controllers/1180/2 "2019-09-06T15:05:11Z")

</div>

> [@testuser](#):
>
> I am trying to add authentication adapter as I’ve describe here [How to add authentication adapter to controller?](https://discourse.zendframework.com/t/how-to-add-authentication-adapter-to-controller/1179) .

Please stay in your original post and do not open multiple threads on the same topic. Thanks!

---

<div class="post-metadata">

**Author:** ![testuser](https://avatars.discourse-cdn.com/v4/letter/t/e495f1/32.png) [@testuser](https://discourse.laminas.dev/u/testuser)\
**Post date:** [September 6, 2019, 6:12pm UTC](https://discourse.laminas.dev/t/how-can-i-stop-throwing-403-forbidden-by-apigility-for-non-rest-non-rpc-controllers/1180/3 "2019-09-06T18:12:06Z")

</div>

Original post was too overall. Now I am interesting how to override getTypeFromMap() method of DefaultAuthenticationListener or it \_\_invoke method or how to stop executing apigility for non-rest/non-rpc controllers?
