Cakephp authenticate authorize only admin without User model - cakephp

I have integrated the Auth component and the Acl component (and behavior) and it all works fine with the User model etc.
Now I would like to have the admin to be completely independent from the User model and the access control lists. Why? Well, because I'm trying to build a CMS which should also work if the client doesn't want a user community in his website.
So I would like the admin to be able to log in without having a user model and once the admin is logged in he should have access to everything, regardless what Acl says...
How do I do that?

You will have to pass an option 'userModel' while declaring AuthComponent in your AppController. Hope this link will help you. Kindly ask if it not worked for you.

Related

user management with Firebase and React

I was wondering if this is possible using Firebase and React.
I want to create a admin panel where the admins can add new user and assign roles. The moderators should also be able to login and make a new post (the new post part i have figured out).
However i dont want any users to be able to register on their own, just the admin to add them to the site.
Is this possible and in that case, how? Grateful for input and thoughts
Yes its possible, just create and Interface which is able to send data to firebase.
Here you have a little example.
I've just create and APP which connects to firebase. Firebase saves a lot of time becase you dont have to control the Auth and the Users SingUp, it has functions to do it.
I will sugest you to use it with ReactForm (to send the data) abd the ReactRedux to control states and the LogIn, LogOut and SignUp.
https://medium.com/firebase-developers/how-to-setup-firebase-authentication-with-react-in-5-minutes-maybe-10-bb8bb53e8834
Fore more info check Google Documentation.
https://firebase.google.com/docs/auth

Role based authentication with firebase and angularjs

I am using email/password authentication via Firebase, so currently I only have authenticated user and non-authenticated user. But for the app, I would like to have admin, moderator, user and guest four different kinds of role.
I did some research, but could not find any existing example or logic to do so. Here are my initial thoughs, but not sure if it is feasible. Basically two steps:
Create a table in firebase called User, while Firebase record the email/password, I also push the data(email/password), and role information to the table.
In the route, check if the user has the appropriate role to access the certain page
Any other better way to do it? Any idea would be appreciated!
I had similar issue while working with role based authorization. I followed same pattern of saving users role and then retriving it when needed. If you are using ui-router for routes then probably you can use angular-permission module which works on the same concept and is easy to use.
You can find that module here: https://github.com/Narzerus/angular-permission

CakePHP and Opauth

I started implementing Opauth for CakePHP. It's awesome that it's easy to login via Facebook, Twitter...
Question is once Opauth returns login data what would be an efficient way to login the user to CakePHP?
Opauth doesn't login the user to CakePHP. I think I'm supposed to create a user and save the facebook or other auth info to the db. Is there a plugin that allows me to do this easily?
One thing I love about CakePHP 2.0 was the way the Auth Plugins work, you can really customize one ore more Authentication methods. At the same time this leaves it to the developer to 'hook in' custom Auth Plugins to integrate the solution.
The plugin page has your answer, almost
Goto https://github.com/uzyn/cakephp-opauth#how-to-use
check step #6 "After validation, user will be redirected to Router::url('/opauth-complete') with validated auth response data retrievable available at $this->data"
after this is complete and you have code like their example public function opauth_complete() {...
in this function you will use the $this->data to find your User that was authenticated
a method I use at times is to find the user by 2 pieces of information that is provided by Opauth example: username and email
you can use something like $loginUser = $this->User->find('first', array('fields'=>array('User.*'), 'conditions'=>array('User.username'=>$this->data['username'], 'User.email'=>$this->data['email']));
once you have the user in $loginUser you can just call the $this->Auth->login($loginUser) and you will now have an AuthSession with that user!
Let me know if you have any questions.

CakePHP 1.3: Public User Profile With Routes Setup

All,
I have a CakePHP app I am developing with user accounts and some social interaction and I am looking to allow each user to have a profile and make it public and whatever information the user decides to make available. Currently the user is able to access his/her personal account at http://www.domain.com/account, but I want the user to also have a profile at http://www.domain.com/users/profile/user234.
What is the best approach?
Create a function profile($username) in my users_controller.php?
Create a profiles_controller.php to handle users profiles?
Is there a better way?
Or is there a CakePHP Profile Plugin available I can use
Also,
Is it possible to use CakePHP routes to have something like this: http://user1234.domain.com?
Thank you for you help!
1 & 2) Both ways work. I would put it profiles controller because its simply more logical but there is not real guideline for that. Usually you do things in the domain they belong to.
3) Not really.
4) Not for profiles but for the whole user thing http://github.com/cakedc/users But be aware that the profiles part is using a key/value storage for the fields of the profile. But you can simply change that by extending the plugins models and controllers on app level - OOP 4tw! :)
For subdomain routing you need to implement a custom route object. See this ticket related to that topic. http://cakephp.lighthouseapp.com/projects/42648/tickets/2429 Lookup the book.cakephp.org if you need to learn how to create custom routes. See http://book.cakephp.org/2.0/en/development/routing.html?highlight=router#custom-route-classes for CakePHP 2.0. And see http://book.cakephp.org/1.3/en/view/1634/Custom-Route-classes for 1.3.

separate login section for admin and normal website user in cakephp 1.3

I am using cakephp 1.3.14 to develop a website. I need to create separate login section/screen for admin and normal website user. I don't want to use same login section for all the users as per my requirements. Admin should have a separate login screen. I need some help with this. How can I implement it in cakephp. Thanks in advance.
You should use prefix routing so that regular users will see /controller/action and admins get their own prefix like /admin/controller/action.
Simply create an admin action and internally "redirect" the controller to use the regular login action. No need to duplicate code. See http://api20.cakephp.org/class/controller#method-ControllersetAction
public function admin_login() {
$this->layout = 'admin_login';
$this->setAction('login');
}
To get another layout for the admin you can check in the beforeFilter() if the prefix is "admin" and set a different layout based on it. Or simply set it in the action as shown above if just needed there.

Resources