CakePHP and OpenID

I got the chance to integrate OpenID authentication into a CakePHP application that I am working on. I tried the OpenID component at first but kept running into troubles with the return_url not matching what was expected. After getting no where for a couple of hours, I found a simpler library to use – the LightOpenID library.

All I had to do was to load it using App::import('Vendor','openid'); and that was it.

The library is pretty straight forward to use and even the examples given were more than enough to get it working. However, I ran into another problem very quickly. Some OpenID worked while others did not. After some investigation, it turned out that it was due to the use of mod_rewrite that caused a url to have two “?” in it. To fix this problem, I forced the return_url to have a “?” in it that made the OpenID provider use a “&” instead.

That was it!

So, the return_url was something like:
http://example.org/index.php?url=user/login?oid&openid.mode=id_res...

Published by

Unknown's avatar

Shawn Tan

Chip Doctor, Chartered/Professional Engineer, Entrepreneur, Law Graduate.

Leave a comment