Index: openid_provider.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openid_provider/openid_provider.inc,v retrieving revision 1.3.2.10 diff -u -p -r1.3.2.10 openid_provider.inc --- openid_provider.inc 20 Oct 2010 17:29:01 -0000 1.3.2.10 +++ openid_provider.inc 30 Oct 2010 20:39:51 -0000 @@ -2,13 +2,18 @@ // $Id: openid_provider.inc,v 1.3.2.10 2010/10/20 17:29:01 walkah Exp $ /** + * @file + * Additional functions used bu OpenID 2.0 Provider. + */ + +/** * Create an association with an RP * * @param array $request */ function openid_provider_association_response($request) { module_load_include('inc', 'openid'); - + $session_type = $request['openid.session_type']; $assoc_type = $request['openid.assoc_type']; $dh_modulus = $request['openid.dh_modulus']; @@ -20,7 +25,7 @@ function openid_provider_association_res // CLEAR STALE ASSOCIATIONS db_query("DELETE FROM {openid_provider_association} WHERE created + expires_in < %d", time()); - + $response = array( 'ns' => OPENID_NS_2_0, 'session_type' => $session_type, @@ -28,7 +33,7 @@ function openid_provider_association_res 'assoc_type' => $assoc_type, 'expires_in' => $expires_in ); - + if ($session_type == 'DH-SHA1' || (($session_type == '' || $session_type == 'no-encryption') && $assoc_type == 'HMAC-SHA1')) { @@ -55,7 +60,7 @@ function openid_provider_association_res // Save the association for reference when dealing // with future requests from the same RP. db_query("INSERT INTO {openid_provider_association} (assoc_handle, assoc_type, session_type, mac_key, created, expires_in) VALUES ('%s', '%s', '%s', '%s', %d, %d)", - $assoc_handle, $assoc_type, $session_type, $mac_key, time(), $expires_in); + $assoc_handle, $assoc_type, $session_type, $mac_key, time(), $expires_in); $message = _openid_create_message($response); @@ -82,7 +87,7 @@ function openid_provider_association_err /** * Generate an authentication response * - * @param + * @param */ function openid_provider_authentication_response($request) { global $user; @@ -125,7 +130,7 @@ function openid_provider_authentication_ if ($request['openid.mode'] == 'checkid_immediate') { // TODO } - + $parts = parse_url($request['openid.return_to']); if (isset($parts['query'])) { $query = $parts['query']; @@ -137,15 +142,15 @@ function openid_provider_authentication_ // calling hook_openid so we can do response parsing and send any pertinent data back to the user $response = array_merge($response, module_invoke_all('openid_provider', 'response', $response, $request)); - + $rp = _openid_provider_rp_load($user->uid, $realm); if ($rp->auto_release) { $response = _openid_provider_sign($response); _openid_provider_rp_save($user->uid, $realm, TRUE); - return openid_redirect_http($response['openid.return_to'], $response); + return openid_redirect_http($response['openid.return_to'], $response); } else { - // Unset global post variable, otherwise FAPI will assume it has been + // Unset global post variable, otherwise FAPI will assume it has been // submitted against openid_provider_form. unset($_POST); return drupal_get_form('openid_provider_form', $response, $realm); @@ -190,7 +195,7 @@ function openid_provider_dh_assoc($reque if (empty($request['openid.dh_consumer_public'])) { return FALSE; } - + if (isset($request['openid.dh_modulus'])) { $mod = _openid_dh_base64_to_long($request['openid.dh_modulus']); } @@ -208,11 +213,11 @@ function openid_provider_dh_assoc($reque $r = _openid_dh_rand($mod); $private = _openid_provider_add($r, 1); $public = _openid_provider_powmod($gen, $private, $mod); - + $cpub = _openid_dh_base64_to_long($request['openid.dh_consumer_public']); $shared = _openid_provider_powmod($cpub, $private, $mod); $mac_key = _openid_provider_dh_xorsecret($shared, $secret, $algo); - $enc_mac_key = base64_encode($mac_key); + $enc_mac_key = base64_encode($mac_key); $spub64 = _openid_dh_long_to_base64($public); return array( 'dh_server_public' => $spub64, @@ -244,11 +249,11 @@ function _openid_provider_dh_xorsecret($ // Request is: Exact copies of all fields from the authentication response function openid_provider_verification_response($request) { $is_valid = TRUE; - + // Use the request openid.assoc_handle to look up // how this message should be signed, based on // a previously-created association. - $assoc = db_fetch_object(db_query("SELECT * FROM {openid_provider_association} WHERE assoc_handle = '%s'", + $assoc = db_fetch_object(db_query("SELECT * FROM {openid_provider_association} WHERE assoc_handle = '%s'", $request['openid.assoc_handle'])); $signed_keys = explode(',', $request['openid.signed']); @@ -270,7 +275,7 @@ function openid_provider_verification_re $message = _openid_create_message($response); header("Content-Type: text/plain"); - print $message; + print $message; } function openid_provider_cancel_authentication_response($mode = 'checkid_immediate') { @@ -301,16 +306,17 @@ function _openid_provider_rp_load($uid, return $rps; } } - + function _openid_provider_rp_save($uid, $realm, $auto_release = FALSE) { $rpid = db_result(db_query("SELECT rpid FROM {openid_provider_relying_party} WHERE uid=%d AND realm='%s'", $uid, $realm)); if ($rpid) { - db_query("UPDATE {openid_provider_relying_party} SET auto_release=%d, last_time=%d WHERE rpid=%d", $auto_release, time(), $rpid); + db_query("UPDATE {openid_provider_relying_party} SET auto_release=%d, last_time=%d WHERE rpid=%d", $auto_release, time(), $rpid); } else { db_query("INSERT INTO {openid_provider_relying_party} (uid, realm, first_time, last_time, auto_release) VALUES (%d, '%s', %d, %d, %d)", $uid, $realm, time(), time(), $auto_release); } } + function _openid_provider_nonce() { // YYYY-MM-DDThh:mm:ssTZD UTC, plus some optional extra unique chars return gmstrftime('%Y-%m-%dT%H:%M:%SZ') . @@ -322,7 +328,7 @@ function _openid_provider_nonce() { function _openid_provider_sign($response) { module_load_include('inc', 'openid'); - + $also_sign = array(); $parts = parse_url($response['openid.return_to']); if (isset($parts['query'])) { @@ -337,13 +343,13 @@ function _openid_provider_sign($response $signed_keys = array('op_endpoint', 'return_to', 'response_nonce', 'assoc_handle', 'identity', 'claimed_id'); $signed_keys = array_merge($signed_keys, module_invoke_all('openid_provider', 'signed', $response)); $response['openid.signed'] = implode(',', $signed_keys); - + // Use the request openid.assoc_handle to look up // how this message should be signed, based on // a previously-created association. - $assoc = db_fetch_object(db_query("SELECT * FROM {openid_provider_association} WHERE assoc_handle = '%s'", + $assoc = db_fetch_object(db_query("SELECT * FROM {openid_provider_association} WHERE assoc_handle = '%s'", $response['openid.assoc_handle'])); - + // Generate signature for this message $response['openid.sig'] = _openid_provider_signature($assoc, $response, $signed_keys); return $response; @@ -375,7 +381,7 @@ function _openid_provider_add($a, $b) { if (function_exists('gmp_add')) { return gmp_add($a, $b); } - else if (function_exists('bcadd')) { + elseif (function_exists('bcadd')) { return bcadd($a, $b); } } @@ -384,7 +390,7 @@ function _openid_provider_powmod($base, if (function_exists('gmp_powm')) { return gmp_powm($base, $exp, $mod); } - else if (function_exists('bcpowmod')) { + elseif (function_exists('bcpowmod')) { return bcpowmod($base, $exp, $mod); } } Index: openid_provider.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openid_provider/openid_provider.install,v retrieving revision 1.2.2.2 diff -u -p -r1.2.2.2 openid_provider.install --- openid_provider.install 15 Feb 2010 21:13:15 -0000 1.2.2.2 +++ openid_provider.install 30 Oct 2010 20:39:51 -0000 @@ -2,6 +2,11 @@ // $Id: openid_provider.install,v 1.2.2.2 2010/02/15 21:13:15 walkah Exp $ /** + * @file + * Install, update and uninstall functions for the openid_provider module. + */ + +/** * Implementation of hook_install(). */ function openid_provider_install() { @@ -95,7 +100,7 @@ function openid_provider_schema() { 'created' => array( 'type' => 'int', 'not null' => TRUE, - 'default' => 0, + 'default' => 0, ), 'expires_in' => array( 'type' => 'int', @@ -107,4 +112,4 @@ function openid_provider_schema() { ); return $schema; -} \ No newline at end of file +} Index: openid_provider.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openid_provider/openid_provider.module,v retrieving revision 1.3.2.7 diff -u -p -r1.3.2.7 openid_provider.module --- openid_provider.module 20 Oct 2010 17:33:56 -0000 1.3.2.7 +++ openid_provider.module 30 Oct 2010 20:39:51 -0000 @@ -67,9 +67,9 @@ function openid_provider_perm() { return array('manage own openid sites', 'administer openid provider'); } - /** - * Implementation of hook_theme() - */ +/** + * Implementation of hook_theme(). + */ function openid_provider_theme($existing, $type, $theme, $path) { return array( 'openid_provider_sites' => array( @@ -78,9 +78,8 @@ function openid_provider_theme($existing ); } - /** - * Implementation of hook_init() + * Implementation of hook_init(). * * Add appropriate HTML headers for XRDS and Link discovery. */ @@ -104,7 +103,7 @@ function openid_provider_sites_access($a */ function openid_provider_user($op, &$edit, &$account, $category = NULL) { global $user; - + switch ($op) { case 'insert': case 'update': @@ -123,7 +122,7 @@ function openid_provider_user($op, &$edi // If the user is deleted, remove the path aliases if (module_exists('pathauto')) { $account = (object) $account; - path_set_alias(openid_provider_user_path($account->uid)); + path_set_alias(openid_provider_user_path($account->uid)); } break; case 'view': @@ -189,7 +188,7 @@ function openid_provider_admin_settings( */ function openid_provider_xrds($account = NULL) { module_load_include('inc', 'openid'); - + if ($account) { $types = array(OPENID_NS_2_0 .'/signon'); } @@ -204,7 +203,7 @@ function openid_provider_xrds($account = if ($account->uid) { $data['LocalID'] = array(openid_provider_url(openid_provider_user_path($account->uid))); } - + $xrds['openid_provider'] = array( 'services' => array( array('priority' => 10, @@ -222,14 +221,14 @@ function openid_provider_xrds($account = function openid_provider_form(&$form_state, $response = array(), $realm = NULL) { global $user; - // Use form_state to store the $response and $realm values + // Use form_state to store the $response and $realm values if (count($response)) { $form_state['storage']['response'] = $response; } else { $response = $form_state['storage']['response']; } - + if ($realm) { $form_state['storage']['realm'] = $realm; } @@ -274,7 +273,7 @@ function openid_provider_form_submit(&$f module_load_include('inc', 'openid'); module_load_include('inc', 'openid_provider'); - + $response = _openid_provider_sign($form_state['storage']['response']); _openid_provider_rp_save($user->uid, $form_state['storage']['realm'], $auto_release); openid_redirect_http($response['openid.return_to'], $response); @@ -286,15 +285,15 @@ function openid_provider_form_submit(&$f function openid_provider_form_submit_always(&$form, $form_state) { return openid_provider_form_submit($form, $form_state, TRUE); } - + /** * Cancel submit handler */ function openid_provider_form_submit_cancel(&$form, $form_state) { module_load_include('inc', 'openid_provider'); module_load_include('inc', 'openid'); - - $return_to = $form_state['storage']['response']['openid.return_to']; + + $return_to = $form_state['storage']['response']['openid.return_to']; $response = openid_provider_cancel_authentication_response($form_state['openid.mode']); openid_redirect($return_to, $response); } Index: openid_provider.pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openid_provider/openid_provider.pages.inc,v retrieving revision 1.1.2.4 diff -u -p -r1.1.2.4 openid_provider.pages.inc --- openid_provider.pages.inc 15 Feb 2010 21:13:15 -0000 1.1.2.4 +++ openid_provider.pages.inc 30 Oct 2010 20:39:51 -0000 @@ -18,7 +18,7 @@ function openid_provider_endpoint($reque if (count($request) == 0) { $request = _openid_response(); } - + if (isset($request['openid.mode'])) { switch ($request['openid.mode']) { case 'associate': @@ -49,7 +49,7 @@ function openid_provider_page($account) */ function openid_provider_continue() { module_load_include('inc', 'openid'); - + if (isset($_SESSION['openid_provider']['request'])) { $request = $_SESSION['openid_provider']['request']; unset($_SESSION['openid_provider']['request']); @@ -87,7 +87,7 @@ function openid_provider_sites_form($for if (!$user) { global $user; } - + module_load_include('inc', 'openid_provider'); $result = pager_query("SELECT * FROM {openid_provider_relying_party} WHERE uid=%d ORDER BY last_time DESC", 50, 0, NULL, $user->uid); @@ -96,7 +96,7 @@ function openid_provider_sites_form($for '#type' => 'item', '#description' => t('Those are the sites you have used your OpenID on. Access control determines determines if you will be asked for approval when login into those sites using your OpenID. You can also completely deny access to those sites if you think they are malicious.'), ); - + $form['submit'] = array( '#type' => 'submit', '#value' => t('Update'), @@ -159,4 +159,4 @@ function theme_openid_provider_sites($fo $output .= drupal_render($form); return $output; -} \ No newline at end of file +}