CodeIgniter authentication + user privileges

2019-01-17 20:02发布

问题:

I'm trying to build an authentication system in my application, but I'm having some problems in deciding which is the best way I could acomplish what I want in CodeIgniter.

The website allows companies to manage their buildings. A company can have many buildings, and many users (when I say users I mean employees from that company).

In this website I would like two have (basically) four general kind of users.

  • Super Admin: This would be able to add new admins and new companies to the database, and give privileges to the rest of the admins.
  • Admin: This would be able to do different stuff depending on the assigned privileges.
  • Company Super User: This user would be created directly when an admin creates a new company. This user would be able to create new users for that company, and since s/he would have total permissions, he would be able to do everything that the other users can do.
  • Company User: Depending on the privileges assigned by its super user, this user would be able to do and see different data (for example, a simple user would just be able to see information from one of the many company buildings).

So, even though I've seen many authentication libraries out there for CodeIgniter, it would be nice to hear any recommendations about how I could design this "authentication role based" system, and if you particularly recommend a library that could help to accomplish this.

Appreciate!

回答1:

There Are many libraries that already handle Authentication within Codeigniter, but the one I would recommend is Ion_Auth. It handles user permissions (groups) very well and I've actually done a detailed writeup outlining a good way to handle this situation with Ion_Auth.



回答2:

I suggest FlexiAuth library which is a re-modified version of ion Auth, and has lot of features already built in, simply out of the box.



回答3:

I've been developing a role based authentication system for Codeigniter called WolfAuth, here's the repository. It's still early days, but it sort of works. You can add roles, etc and then restrict functions and classes to particular user roles and usernames.



回答4:

Use CI_aauth. I like this, this is very good from others auth.

https://github.com/kabircse/CodeIgniter-Aauth