MySQL support for OpenID component

Published on and tagged with cakephp  component  openid

Up to now the OpenID component stored all data in the file system (in app/tmp/openid) even though the OpenID library provided by JanRain also supports databases. I wanted to provide support for MySQL for quite some time, but I wanted too much (i.e. the perfect CakePHP solution *g*), and so this feature never materialized…

Anyway, in the meantime I used a more pragmatic approach and used what’s already there. So, instead of using CakePHP for accessing the database, the superseded PEAR DB package is used…

If you want to use the OpenID component with MySQL, you have to perform the following steps:

  • Download the latest version of the OpenID component
  • If you already use the component, simply replace it with the new version. In the other case follow the installation instructions from the download page
  • Execute the SQL script included in the zip file to create the necessary tables
  • Download the PEAR base system and place PEAR.php from the zip in vendors/pear
  • Download PEAR DB and place DB.php and the DB folder from the zip in vendors/pear
  • In the file which uses the OpenID component add: Configure::write(‘Openid.use_database’, true);
  • If you want to use a database configuration other than “default” you can specify it with: Configure::write(‘Openid.database_config’, ‘name_of_database_config’);

With that, the data should now get stored in the database. If there are any questions/problems/whatever, please leave a comment!

Bake a comment




(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License