A3M – A CodeIgniter Account Authentication & Authorization Module Installation
A3M has been updated: http://blog.biernacki.ca/2012/07/a3m-updated-to-latest-codeigniter-v2-1-2-named-pbj/.
Please be aware, that this guide is currently outdated.
So I became interested in creating a CodeIgniter openid application. I really like the concept having used StackOverflow so long, that I decided to start looking for a means to do it. After some searching and StackOverflow posting, I found a3m.
A3M in a nutshell
a3m is a great OpenID module for CodeIgniter, and what really sold me on it was it’s complete support of all the major openid providers (google, yahoo, myspace, facebook, etc). It allows you to just build on it and not worry about the typical CRUD that developers go through in regards to user accounts. I’m really glad that I can take something, plug it in, and run with it, building my web application without building the ground work for user connections, something that as a developer you typically have to re-build on EVERY project.
Overall, it gives users a convenient means of connecting with my application, they don’t need to make yet another username/password that they might forget, or just make really weak security wise.
Problems with a3m?
Main issue I found with a3m, is that the developer didn’t have time to fully document the installation of said application. Maybe in the future with a full 1.0 release we will have a complete easy to use guide, but for now my post here aims for that documentation goal. Anyway, it basically comes down to a couple things, but having gone through google searches, and codeigniter forum posts, I can tell you people keep making the same installation mistakes during installation/config.
So the documentation is pretty poor when it comes to this app. I hope with this post to at least give you a better starting position and eliminate some of the small user created issues (read.. not bugs!).
Oh and lastly, the project is questionable right now due to lack of ‘movement’ since March 2010 (as of this post). So hopefully the developer will contribute some updates.
How to start
- Download a3m (which comes already with CodeIgniter 1.7.2 — as of this posting)
- Extract the contents into your web directory (using an unzip app like 7zip). Personally I put everything into the root, and didn’t use the ‘a3m’ folder.
- Using a mysql client (phpmyadmin or a desktop version like heidi sql), create a database and import the application data from the ‘a3m/a3m.sql’ file.
- Once the database is setup, create a unique user account / password to access said database (you will need this for the next section).
Configs & Permissions
So now you’ve got the app extracted, you have your database prepared, privileges setup and ready to be used by your application, all you have to do is modify the configs to reflect your setup.
- Edit the following file /system/application/config/database.php and modify your settings just like you would for any CodeIgniter project.
- (optional) Modify your .htaccess file if you were like me and put the application into the root directory of your website (remove a3m folder reference).
- (optional) If your server / apache / webhost is on a linux box, you will need to modify some permissions on your folder structure. I learned this through trial and error as no openid / google / yahoo account would validate (It couldn’t store the data locally in the cache).
I chown’ed the following folders and put them assigned www-data ownership (lets Apache have read/write access) :
– /uploads/ (all your images / user uploaded content)
– /system/cache/ (critical for openid nonces)
- With permissions set (optional) and the database configured, you only have one more things to edit, and this takes place inside the /system/application/modules/account/config/ folder, so lets edit account.php
- account.php needs to be configured, so that you can actually play with your a3m setup. In my case, I wanted to develop the app without any SSL or reCaptcha support out of the box (by default those 2 are enabled (which breaks your login process as it tries to redirect you to the https site or enable reCaptcha), so lets disable them:
$config['ssl_enabled'] = FALSE; $config['sign_in_recaptcha_enabled'] = FALSE; $config['sign_up_recaptcha_enabled'] = FALSE; $config['sign_up_auto_sign_in'] = FALSE; $config['sign_up_recaptcha_enabled'] = FALSE; $config['sign_up_auto_sign_in'] = FALSE;
also while we are in there, you can configure your outbound password recovery email:
$config['password_reset_email'] = 'firstname.lastname@example.org';
And there you have it. Config’s are all done with (for a basic start at least). Simply navigate now to your website and enjoy testing the a3m interface. I created some fake demo accounts to test with, one of my favorite openid ones to test with is https://www.myopenid.com/ so start there if you want to create a quick account and test with. You can then begin building your CodeIgniter application, while utilizing the a3m module for all your login needs.
If you run into problems always refer to your apache / php logs and find out the cause. If it is simply failing to validate your openid account (even tho you signed in) you need to verify your permissions on the cache folder.