2007-06-18 16:09:39 +00:00
<?php
2009-05-13 19:42:18 +00:00
/**
* @file
* Install, update and uninstall functions for the openid module.
*/
2007-10-05 14:43:26 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_schema().
2007-10-05 14:43:26 +00:00
*/
function openid_schema() {
$schema['openid_association'] = array(
2008-11-15 13:01:11 +00:00
'description' => 'Stores temporary shared key association information for OpenID authentication.',
2007-10-05 14:43:26 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'idp_endpoint_uri' => array(
'type' => 'varchar',
'length' => 255,
2008-11-15 13:01:11 +00:00
'description' => 'URI of the OpenID Provider endpoint.',
2007-10-10 11:39:35 +00:00
),
'assoc_handle' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
2008-11-15 13:01:11 +00:00
'description' => 'Primary Key: Used to refer to this association in subsequent messages.',
2007-10-10 11:39:35 +00:00
),
'assoc_type' => array(
'type' => 'varchar',
'length' => 32,
2008-11-15 13:01:11 +00:00
'description' => 'The signature algorithm used: one of HMAC-SHA1 or HMAC-SHA256.',
2007-10-10 11:39:35 +00:00
),
'session_type' => array(
'type' => 'varchar',
'length' => 32,
2008-11-15 13:01:11 +00:00
'description' => 'Valid association session types: "no-encryption", "DH-SHA1", and "DH-SHA256".',
2007-10-10 11:39:35 +00:00
),
'mac_key' => array(
'type' => 'varchar',
'length' => 255,
2008-11-15 13:01:11 +00:00
'description' => 'The MAC key (shared secret) for this association.',
2007-10-10 11:39:35 +00:00
),
'created' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
2008-11-15 13:01:11 +00:00
'description' => 'UNIX timestamp for when the association was created.',
2007-10-10 11:39:35 +00:00
),
'expires_in' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
2008-11-15 13:01:11 +00:00
'description' => 'The lifetime, in seconds, of this association.',
2007-10-10 11:39:35 +00:00
),
2007-10-05 14:43:26 +00:00
),
'primary key' => array('assoc_handle'),
);
2010-08-22 22:00:16 +00:00
$schema['openid_nonce'] = array(
'description' => 'Stores received openid.response_nonce per OpenID endpoint URL to prevent replay attacks.',
'fields' => array(
'idp_endpoint_uri' => array(
'type' => 'varchar',
'length' => 255,
'description' => 'URI of the OpenID Provider endpoint.',
),
'nonce' => array(
'type' => 'varchar',
'length' => 255,
'description' => 'The value of openid.response_nonce.',
),
'expires' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'A Unix timestamp indicating when the entry should expire.',
),
),
'indexes' => array(
'nonce' => array('nonce'),
'expires' => array('expires'),
),
);
2007-10-05 14:43:26 +00:00
return $schema;
}
2009-08-29 21:07:43 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_requirements().
2009-08-29 21:07:43 +00:00
*/
function openid_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
// Check for the PHP BC Math library.
2011-01-13 01:12:18 +00:00
if (!function_exists('bcadd') && !function_exists('gmp_add')) {
$requirements['openid_math'] = array(
2009-08-29 21:07:43 +00:00
'value' => t('Not installed'),
'severity' => REQUIREMENT_ERROR,
2012-03-24 06:14:35 +00:00
'description' => t('OpenID suggests the use of either the <a href="@gmp">GMP Math</a> (recommended for performance) or <a href="@bc">BC Math</a> libraries to enable OpenID associations.', array('@gmp' => 'http://php.net/manual/book.gmp.php', '@bc' => 'http://www.php.net/manual/book.bc.php')),
2011-01-13 01:12:18 +00:00
);
}
elseif (!function_exists('gmp_add')) {
$requirements['openid_math'] = array(
'value' => t('Not optimized'),
'severity' => REQUIREMENT_WARNING,
2012-03-24 06:14:35 +00:00
'description' => t('OpenID suggests the use of the GMP Math library for PHP for optimal performance. Check the <a href="@url">GMP Math Library documentation</a> for installation instructions.', array('@url' => 'http://www.php.net/manual/book.gmp.php')),
2009-08-29 21:07:43 +00:00
);
}
else {
2011-01-13 01:12:18 +00:00
$requirements['openid_math'] = array(
2009-08-29 21:07:43 +00:00
'value' => t('Installed'),
);
}
2011-01-13 01:12:18 +00:00
$requirements['openid_math']['title'] = t('OpenID Math library');
2009-08-29 21:07:43 +00:00
}
return $requirements;
}
2010-08-22 22:00:16 +00:00
/**
2012-06-29 13:35:20 +00:00
* Implements hook_update_last_removed().
2010-08-22 22:00:16 +00:00
*/
2012-06-29 13:35:20 +00:00
function openid_update_last_removed() {
return 6000;
2010-08-22 22:00:16 +00:00
}