
Photo: Wikipedia Tank Auth by Ilya Konyukhov is regarded as one of the best authentication libraries for CodeIgniter. Tank Auth is the top recommendation on this landmark CodeIgniter authentication thread at stackoverflow for it’s rock solid security features. But one drawback of Tank Auth is that it has no support for groups or roles out of the box (‘admins’, ‘users’, etc). In this post we’re going to add the most minimal groups/roles support to Tank Auth possible. In the spirit of clean and object oriented code principles, we won’t change any code in the core Tank Auth library, only extend it with our own class. I’m not opposed to hacking things together, when it’s a good fit for the goals of the project. But my goal for this extension of Tank Auth is to not touch any Tank Auth code at all and keep things as minimal as possible. (UPDATE: “Tank Auth Groups” is now packaged with install instructions on github)
The approach outlined here makes a few assumptions.
- Tank Auth 1.0.9 installed in CodeIgniter 2.1.0
- MySQL (5)
- The default group ID will be ’300′
- The admin group ID will be ’100′
Here is an overview of the steps…
- Add a group/roles column to the users table in the database
- Create a library in CodeIgniter that extends Tank Auth with groups/roles support
- Create a model in CodeIgniter that extends the Tank Auth ‘users.php’ model
- Change everywhere the Tank Auth library is loaded to the new library
John Wright (



