I Need Help with Implementing Authentication in CakePHP 4.x

Hey CakePHP peeps! :wave:

I am Building an awesome application here, but authentication is throwing me a bit of a curveball. I’ve been digging through the docs, but my brain is still in a bit of a knot when it comes to setting things up for different user roles and implementing custom logic. I’ve tried a couple approaches, but nothing’s clicking just right.

Anyone able to lend a hand? Maybe walk me through the process or share some code examples to shed some light on how to get authentication dialed in with CakePHP 4.x? All tips, tricks, and resources are seriously welcome!
I also check this : https://discourse.cakephp.org/t/manually-logging-users-using-authentication-pluginincakeruby But I have not found any solution.

Thanks a million in advance!

Respected member :innocent:

both auth plugins should be seen as building blocks to build whatever auth system you want - not a ready made auth system.

In my workshop I just show you how to set it up but what you built upon it is completely up to you.

There is of course an easier approach by just using GitHub - CakeDC/users: Users Plugin for CakePHP
It has RBAC already pre-configured with a separate permissions file where you can rather easily configure which roles are allowed to do what.

Also there is GitHub - dereuromark/cakephp-tinyauth: CakePHP TinyAuth plugin for an easy and fast user authentication and authorization. Single or multi role. DB or config file based. which is quite popular as far as I know but I have never used it.

1 Like

I used the CakePHP tutorial app to get a handle on authentication and authorisation