# Authorization Tutorial for cakePHP 4

**URL:** https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896
**Category:** Need Help
**Created:** [June 3, 2020, 4:17pm UTC](https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896 "2020-06-03T16:17:17Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![noalts](https://avatars.discourse-cdn.com/v4/letter/n/bc8723/32.png) [@noalts](https://discourse.cakephp.org/u/noalts)
#### Post date: [June 3, 2020, 4:17pm UTC](https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896/1 "2020-06-03T16:17:18Z")

</div>

Hello,

after following the Tutorials to the end of the Authorization part, everything works until I press ‘submit’ on the login page. Then the following error massage shows up:

 ![CakePHP Authorization](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/c/c9de0d883e87a0383882350afb4307769ffa9852.png)

And if I want to edit an article this error occurs:

# Policy for `Cake\ORM\Entity` has not been defined.

I’ve followed the Tutorial the second time, and went over the last part twice. I can’t make out the mistake.

I would like to know if that is a known issue?  
Or if someone could point out where I could have made a mistake.

Thank you for your help.

noalts

---

<div class="post-metadata">

### Author: ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)
#### Post date: [June 3, 2020, 5:24pm UTC](https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896/2 "2020-06-03T17:24:54Z")

</div>

This might take care of your fist error (if I’m not mis-remembering):

[https://book.cakephp.org/authorization/2/en/middleware.html#ensuring-authorization-is-applied](https://book.cakephp.org/authorization/2/en/middleware.html#ensuring-authorization-is-applied)

---

<div class="post-metadata">

### Author: ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)
#### Post date: [June 3, 2020, 6:14pm UTC](https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896/3 "2020-06-03T18:14:20Z")

</div>

It’s weird that the “login” process seems to somehow be hitting the “/users” URL. Is the login function redirecting there after successful login? That doesn’t seem like a place that people would normally be sent to at that time.

---

<div class="post-metadata">

### Author: ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)
#### Post date: [June 4, 2020, 2:53am UTC](https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896/4 "2020-06-04T02:53:41Z")

</div>

Well, login is probably in the UsersController, so it doesn’t feel too surprising to me. He may never be getting out of the login method.

---

<div class="post-metadata">

### Author: ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)
#### Post date: [June 4, 2020, 4:19am UTC](https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896/5 "2020-06-04T04:19:39Z")

</div>

But the URL in the error is just `/users`, not `/users/login`. Standard notation would indicate that this is the _list_ of users. So, unless the routing has been set up such that the login method is accessible at `/users`, there’s a redirect happening, and it’s to an unusual location. Of course, this is all guesswork, because no code has been shared.

---

<div class="post-metadata">

### Author: ![truper](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/truper/32/1882_2.png) [@truper](https://discourse.cakephp.org/u/truper)
#### Post date: [June 20, 2020, 4:45pm UTC](https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896/6 "2020-06-20T16:45:13Z")

</div>

Once you include Authorization, every action in every controller requires an authorization check.

So, for every controller in your project, you will need to add the following as the first line of each action method if you did not already add an authorization check to the action.

> $this-\>Authorization-\>skipAuthorization();

The tutorial would have already added some authorization checks to some of your action methods including the skipAuthorization to your login and logout actions in the user controller.

Hope this helps.

---

<div class="post-metadata">

### Author: ![ironbone](https://avatars.discourse-cdn.com/v4/letter/i/779978/32.png) [@ironbone](https://discourse.cakephp.org/u/ironbone)
#### Post date: [August 21, 2020, 12:19pm UTC](https://discourse.cakephp.org/t/authorization-tutorial-for-cakephp-4/7896/7 "2020-08-21T12:19:45Z")

</div>

It seams you do not have the Entity class for Articles. It must be created when using this type of authorization.
