I want to build an application with CakePHP 2.1 where users are only required to login to the backend (with a custom prefix) and not the front end.
I know it would be possible to do this on a per-action basis with $this->Auth->allow(), but I want to do this based on the prefix.
To archieve this, you can follow the “standard” steps in the Authentification Tutorial and just have to add a little piece in the
beforeFilter()-callback in yourAppController.This will allow users to do everything in your application except all actions with the prefix
admin. The only action allowed isadmin_loginwhich probably resides on some kind of UsersController to make it possible for backend users to log in.Be careful to define this for each prefix that needs authentification if you use multiple prefixes.