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.


Example of a3m login form utilizing openidSo 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

  1. Download a3m (which comes already with CodeIgniter 1.7.2 — as of this posting)
  2. 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.
  3. 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.
  4. 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.

  1. Edit the following file /system/application/config/database.php and modify your settings just like you would for any CodeIgniter project.
  2. (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).
  3. (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)
  4. 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
  5. 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'] = 'no-reply@reset.website.com';
    

All done…

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.



  • James Leven

    Glad someone finally wrote a tutorial helping to setup the library, however I was hoping for SOME documentation, as you mentioned is the major flaw. So you know, how to get it going and recognizing peoples usernames/other info, how to do things and treat them as members, etc.

    Either way, cheers to a nice setup tutorial.

  • http://www.cloudgroup.com.au Christian Marth

    Very Nice post, Just what i was looking for to tie all the A3M pieces together nicely, Well Done!

  • http://www.biernacki.ca Jakub

    @James Leven:

    A3m’s goal is to give you the ‘tie-in’ for account signup / registration. From here on out, you can build on the app just like you would with any CodeIgniter project, add a permission table (roles), create an administration section to ban users, etc. From the roadmap, I read that a3m should support something like this in the future, but I am not aware of it being possible now. You are basically on your own after the installation.

    My main goal was to utilize a3m as an easy way for my users to log in/out of my web app. I am working on the backend for management / functionality on my own. Stay tuned, maybe I will provide a modification that might benefit some people, but no promises. ;)

  • http://jontroth.com @jontroth

    Great walk through!

    I haven’t seen any activity on the code since March 2010 … though I am hoping and looking forward to a new CI2 version. :)

    Not to turn anyone away from A3M, but Pat Andrew has put together a nice package for CI2 called Mauth. And it looks as though he’ll be adding other features like OAuth and OpenID soon.

    You can download it from http://bitbucket.org/missionsix/mauth/src in case you are curious.

  • next2u

    Hi,

    I just get “Disallowed Key Characters.” and no more information about the real error … .

    Regards N.

  • pk

    hey guys,

    thanks for your interest in a3m.
    jakub thanks for writing this post.
    i’ve made jakub the project owner of the open source a3m code on google code. we can fix and improve from there collaboratively. jakub can add more collabators as he see fit from now on.

    i’ve been quiet since mar but i been using a3m in many ways and have learn much about its short comings and more. jakub can we start a google group mailing list of a3m? things like acl, oauth are not stable in the a3m avaliable now. everything else should be fairly stable (tho of cause many small here-and-there improvement are needed)

    contact me at pengkong@mail.com if needed

  • http://www.biernacki.ca Jakub

    @next2u, here are some details for you to check with, might be because you are running a localhost install with a host file modification, details here:

    http://www.snaver.net/2010/01/17/disallowed-key-characters-codeigniter-error/

  • Dan LaManna

    Hey man, great tutorial to get people started. I guess my main issue is I already had my custom .htaccess for getting mod-rewrite to work. Now I’m left clueless as to how to get it working, I took all the files out of the a3m download that were different from my pre-existing CI installation and placed them in the appropriate places, is there a better way of doing it?

  • pk

    hey guys, i’ve just release v1.0 of a3m.

    http://code.google.com/p/a3m/

    still in the process of creating wiki help pages.

  • Mindtricks

    @Jakub

    Can you provide us with example code for the backend you’re working on?

  • http://www.biernacki.ca Jakub

    @Mindtricks, I will try to release some of the code that I have, what I have done is strip out the ‘login/password’ model from the a3m, because I quite frankly want a PURE openid solution. So I removed all that garbage. Also I hate some of the structure that a3m has (stored in modules, hidden away somewhere – views / controllers / etc).

    I removed all those. And it works beautifully, however as I was working on this PK released the updated version of all the code, so I’m sure some things are a bit outdated (I honestly haven’t had time to try the new code yet). So keep in mind the stuff I use is setup for CI2.0.X with the pre-CI2 a3m package reorganized.

  • zuko

    Any similar just PHP library?

  • http://defaulttricks.com/ Mohit Bumb

    huh cool thanks man got your link from stack overflow

  • Aadgxfhf

    sgsshhheeg

  • http://www.facebook.com/people/-Johan-Ferdianto/1727990732 -Johan Ferdianto

    Thankyou very much brother…,

  • http://www.facebook.com/ShivarajRH Shivaraj RH

    hello, I request you to provide steps or documentation for
    How to integrate in my existing CI projects?

  • Jakub

    @Shivaraj as this guide is outdated, take a look at the github source, and look at what can be ported over (effectively you grab the openid / auth models + libraries). https://github.com/pengkong/A3M-for-CodeIgniter-2.0

  • http://www.giftsspace.com/blog Online Strategies

    Great tutorial. I am trying this but now getting error when connecting to facebook it throws error “An error occurred. Please try again later.