php CodeIgniter 认证+用户权限
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4977707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CodeIgniter authentication + user privileges
提问by Nobita
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.
我正在尝试在我的应用程序中构建一个身份验证系统,但是在决定哪种是我可以在 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.
因此,即使我已经看到许多用于 CodeIgniter 的身份验证库,如果您特别推荐一个可以帮助实现此目的的库,也很高兴听到有关我如何设计这个“基于身份验证角色”的系统的任何建议.
Appreciate!
欣赏!
采纳答案by jondavidjohn
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 writeupoutlining a good way to handle this situation with Ion_Auth.
有许多库已经在 Codeigniter 中处理身份验证,但我推荐的是Ion_Auth。它可以很好地处理用户权限(组),实际上我已经做了详细的文章,概述了使用 Ion_Auth 处理这种情况的好方法。
回答by CodeIgniter Expert
回答by Kabir Hossain
Use CI_aauth. I like this, this is very good from others auth.
使用 CI_aauth。我喜欢这个,这对其他人来说非常好。
回答by Dwayne Charrington
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.
我一直在为 Codeigniter 开发一个名为 WolfAuth 的基于角色的身份验证系统,这是存储库。现在还为时尚早,但它有点工作。您可以添加角色等,然后将功能和类限制为特定的用户角色和用户名。