• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

Developing The Ultimate Authentication Library For Codeigniter

Codeigniter · July 28, 2011

Codeigniter’s lack of an authentication system is both a blessing and a curse. The blessing is that you don’t need to conform to a pre-written and and conventionalised auth library, the curse is that writing your own can cause severe headachaes and countless hours of developing something that comes standard in most other PHP frameworks.

I am a huge fan of CakePHP’s authentication library, it has an ACL and Auth system baked in, which works really well and is super extensible, but the framework itself is a proverbial piece of shit disguised as a PHP framework.

FuelPHP has an awesome authentication library and powerful ACL functionality, it is an awesome framework and with a little work it could be ported to Codeigniter, but it still won’t do everything an auth/acl system should.

All of this has led me down the path of creating an authentication system so powerful it does everything, but is simple enough for anyone to use. My first attempt was WolfAuth, an authentication library for Codeigniter that sort of failed due to my lack of understanding of just what an auth system should have, until now.

I have been slowly and patiently rewriting WolfAuth to be an authentication roman warrior meets ninja type library for Codeigniter. It’s driver based, has a permissions system and most of all is easy to use. My current version works quite well, but it sadly relies on DataMapper ORM for Codeigniter which a lot of people don’t understand and use in their projects.

Due to the complexities of building a powerful auth system, DataMapper has allowed me to create relatively complex methods in WolfAuth really easily without the need of complex join queries and sub queries. You realise just how complex something relatively simple in theory can be when it comes to writing the database interaction stuff. It’s not that I don’t know MySQL, writing advanced database queries, and then optimising them is a pain in the ass and takes forever.

So my late night, early morning trade rides to work coding binges have resulted in a pretty awesome auth library, the likes of which the Codeigniter community hasn’t seen yet. WolfAuth aims to be the definitive auth solution for Codeigniter and within 2 weeks, a beta version of many beta versions will be released for you all to try.

Dwayne

Leave a Reply Cancel reply

29 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
zofrex
zofrex
11 years ago

I’ll be keeping a close eye on this, I’ve written my own session and auth libraries for CI after finding everything else that’s out there wanting!

0
Jacob
Jacob
11 years ago

If you can develop something that beats IonAuth in terms of ease of use and functionality, you’ll be on a winner.

0
Dwayne
Dwayne
Author
11 years ago

That’s hopefully the plan. I’m currently rewriting a few things I’m not happy with, but there’ll be two ways of doing everything via the use of class functions or helper functions which are merely wrappers for accessing the class functions.

If anyone has any suggestions feature wise, let me know.

0
Jacob
Jacob
11 years ago

Excellent 🙂

I’m sure you’ve read that fantastic post over on StackOverflow (http://stackoverflow.com/questions/346980/what-codeigniter-authentication-library-is-best) which seems to highlight the features that people expect. There’s also some good stuff in the IonAuth thread on the CI forums.

Just to let you know, I found your post because I’ve got a Spark set up for Codeigniter in Google+. Are you on there yet?

0
David
David
11 years ago

If you could release a version for DataMapper and one without that will be fantastic. Alot of people don’t actually use DataMapper so people will mostly likely use a differen’t auth system.

0
Dwayne
Dwayne
Author
11 years ago

Jacob,

Yeah man, I’ve read that quite a few times. I used to come across it a lot when I was searching for other auth libraries people have developed, quite a legendary thread in terms of the perfect auth library.

David,

Yeah, I will release a non-DataMapper version eventually. The current code is so dependent on it for the roles and permissions stuff because quite frankly it’ll require a few joins or so to port over. Having said that, I could just include a copy of DataMapper in the auth library and load it when I need it.

Because DataMapper is just a library, it doesn’t overwrite or overload any Codeigniter database stuff, so you can use both, I think the DataMapper library even uses Codeigniter database functions.

Do you foresee a problem including DataMapper and just including it for the library?

0
David
David
11 years ago

I dont see any problems including it as a library attached to your auth system. I’m looking forwards to seeing the first version. When are you likely to release it?

Will you also be doing Facebook and twitter integration?

0
SoTrue
SoTrue
11 years ago

So excited for this. I hate Ion Auth, it sucks. It’s so restricted, please implemented support for user meta that doesn’t require you to define what meta variables you allow in the config file like Ion Auth. It would be good if you could have unlimited user meta without having to define the field names and update the database.

0
Brad
Brad
11 years ago

+1 for facebook/twitter integration. Cannot wait to see the new version.

-Brad

0
Dwayne
Dwayne
Author
11 years ago

I’m almost ready to release a beta of this. No Facebook or Twitter drivers for it during the beta, but they’ll eventually come hopefully from community input. With exception of getting the create user function to work, it’s all ready to test. The whole point of the beta is to find things I missed and bugs I missed.

There won’t be any documentation during beta either, but the goal is to have extensive documentation like Codeigniter. Working on the helper for the auth library, so everything is a little easier to access.

0
Heldrida
Heldrida
11 years ago

For the non-Datamapper version, you can get all Datamapper generated queries trough $object->check_last_query(). Maybe when releasing wolfAth someone can do it!

This is not the release version you’re talking right ?
https://github.com/Vheissu/WolfAuth-for-Codeigniter-2.0-#readme

0
Dwayne
Dwayne
Author
11 years ago

Heldrida ,

Great idea, never actually thought of doing that! And no, that’s not the release version I’m talking about. That was an attempted rewrite, which was really just using old code, new version will be a complete rewrite.

The current code I have works on my machine, just debating whether or not to release it now in extreme beta form and let people test.

0
Heldrida
Heldrida
11 years ago

Thanks for looking my tip! I think you should not rely on Datamapper for production, but for prototyping. So, having only the queries, will make your Auth less dependent on Datamapper development. I’m a Datamapper user myself.

0
Heldrida
Heldrida
11 years ago

There’s interesting things coming up on ORM for PHP, check this project out http://redbeanphp.com/

0
Dwayne
Dwayne
Author
11 years ago

Ahh nice, Redbean looks good. I’m just going to release WolfAuth now and then continuously make changes to it. I’ve been working on it so long my brain is a little cloudy, so fresh perspectives on my code might be a good idea and picking up any bad practices, errors in my code.

0
Heldrida
Heldrida
11 years ago

Redbean is the bomb! =D

0
Dwayne
Dwayne
Author
11 years ago

Okay, I’ve just sent the code live. Go nuts everyone! Start nit-picking, fixing things and logging issues on the repo if you find something wrong.

0
Heldrida
Heldrida
11 years ago

Yeah! Thanks a lot for sharing ;D

0
Heldrida
Heldrida
11 years ago

Dwayne, are you going to create a CI Forum Thread anouncing ? that would be nice. Tks

0
Dwayne
Dwayne
Author
11 years ago

Heldrida,

Yeah man, just created a thread here: http://codeigniter.com/forums/viewthread/195846/ – no worries, looking forward to the feedback I’ll hopefully receive on it. It’ll stay as DataMapper driven (for now), but then it’ll fall back on the CI ActiveRecord class once I or others port it over by getting the queries DataMapper spit out and using them 😉

0
Pisyek
Pisyek
11 years ago

“FuelPHP has an awesome authentication library and powerful ACL functionality”

i just want to be clear with fuelphp, is it has its own authentication system? internally?

P.s: Just started to learn this framework. 🙂

0
Dwayne
Dwayne
Author
11 years ago

Pisyek,

Yeah dude. It has an authentication library (driver based) and an ACL library rolled into the framework. Authentication and ACL are too different beasts, but yeah if you want functionality out of the box to restrict pages to authenticated users and want register and login functionality FuelPHP has you covered.

Learning the framework should be pretty easy if you’re familiar with Codeigniter or any other framework for that matter. It’s a good framework to learn, just needs more uptake to stop it from dying, there aren’t many people contributing to the core so I am a little sceptical at present that it’ll survive for a long time unless more people start contributing.

0
Tárcio Zemel
Tárcio Zemel
11 years ago

An Auth Library to CodeIgniter using DataMapper?! WOW

You Git this?

0
Dwayne
Dwayne
Author
Reply to  Tárcio Zemel
11 years ago

Yeah dude, it’s called WolfAuth. Haven’t updated it in a while though and sparse documentation. Will be making a few changes shortly. https://github.com/Vheissu/WolfAuth-for-Codeigniter-2.0-

0
Tárcio Zemel
Tárcio Zemel
11 years ago

Dwayne,

Great! Just a doubt: the actual stable version of DataMapper not runs in CI 2.x. So, DM, in this case, it’s only to the WolfAuth?

0
GDmac
GDmac
11 years ago

Just found your Auth-library. I’ve been diving into and working with DataMapper for some time now (The WanWizard version), and for my app i went with the basic included login_manager library approach from the included bug-tracker example. However your auth-system seems much more elaborate with roles and permissions, and looks like a well thought-out approach. Am i right that this should probably hook into your existing app easily, if you’re already using CI DataMapper?

0
Abhay
Abhay
10 years ago

Just came by this one. So far good 🙂 keep it up

0
Dwayne
Dwayne
Author
10 years ago

Abhay,

If you checkout the develop branch which doesn’t rely on DataMapper any more, it’s usable. It still requires pieces added in like emailing functionality but it allows you to login, check roles and other basic things like that.

0
Abhay
Abhay
10 years ago

Much less files. I will definitely check that 🙂 thanx for the info.

0

Primary Sidebar

Popular

  • Testing Event Listeners In Jest (Without Using A Library)
  • How To Get The Hash of A File In Node.js
  • Waiting for an Element to Exist With JavaScript
  • Thoughts on the Flipper Zero
  • How To Get Last 4 Digits of A Credit Card Number in Javascript
  • How To Paginate An Array In Javascript
  • How To Mock uuid In Jest
  • How to Copy Files Using the Copy Webpack Plugin (without copying the entire folder structure)
  • Reliably waiting for network responses in Playwright
  • Wild Natural Deodorant Review

Recent Comments

  • Dwayne on Is Asking Developers How to Write FizzBuzz Outdated?
  • kevmeister68 on Is Asking Developers How to Write FizzBuzz Outdated?
  • Kevmeister68 on Start-Ups and Companies That Embrace Work From Anywhere Will Be More Likely to Survive the Coming Recession in 2023
  • kevmeister68 on What Would Get People Back Into the Office?
  • Dwayne on PHP Will Not Die

Copyright © 2023 · Dwayne Charrington · Log in

wpDiscuz