OpenID for the mathematically challenged

Published:

The other day I got the OpenID bee in my bonnet and grabbed James Walker's module and installed it on my server. Actually I grabbed it from CVS, and then discovered that the CVS version is half-ported to some new Drupal 6 form API, so I ended up using the DRUPAL-5 tag.

Anyway, I use Dreamhost which I love for many many reasons (primarilly it's really cheap and seems to work really well). Unfortunately they don't build their PHP with BCMath or even GMP, which means my PHP can't do the hard math that's required for crypto. Luckily there's a mode of OpenID that doesn't require any work on the relaying party side. So I made a small change that allows James' module to work in this "dumb" mode.

Index: openid.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openid/openid.install,v
retrieving revision 1.2
diff -u -p -r1.2 openid.install
--- openid.install      25 Mar 2007 06:38:00 -0000      1.2
+++ openid.install      16 May 2007 22:59:56 -0000
@@ -2,24 +2,6 @@</code>

/** - * OpenID module requires bcmath - */ -function openid_requirements($phase) { - if ($phase == 'runtime') { - $requirements['bcmath']['title'] = t('BCMath'); - if (function_exists('bcadd')) { - $requirements['bcmath']['severity'] = REQUIREMENT_OK; - $requirements['bcmath']['value'] = t('Enabled'); - } - else { - $requirements['bcmath']['severity'] = REQUIREMENT_ERROR; - $requirements['bcmath']['description'] = t('OpenID needs the bcmath extension for encryption.'); - } - } - return $requirements; -} - -/** * Implementation of hook_install */ function openid_install() { Index: openid.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openid/openid.module,v retrieving revision 1.2 diff -u -p -r1.2 openid.module --- openid.module 25 Mar 2007 06:38:00 -0000 1.2 +++ openid.module 16 May 2007 22:59:56 -0000 @@ -133,10 +133,14 @@ function openid_login_form_submit($formi

$idp_endpoint = $services[0]['uri']; $_SESSION['openid_idp_endpoint'] = $idp_endpoint; - $assoc_handle = openid_association($claimed_id, $idp_endpoint); - if (empty($assoc_handle)) { - drupal_set_message(t('OpenID Association failed'), 'error'); - return; + + // if we have BCMath, we should use OpenID smart mode + if (function_exists('bcadd')) { + $assoc_handle = openid_association($claimed_id, $idp_endpoint); + if (empty($assoc_handle)) { + drupal_set_message(t('OpenID Association failed'), 'error'); + return; + } }

Also, I put the patch up on Drupal.org