| 1 |
<?php |
<?php |
| 2 |
// $Id: openid.module,v 1.2.2.3 2007/05/24 15:01:21 walkah Exp $ |
// $Id: openid.module,v 1.2.2.4 2007/07/28 03:05:47 walkah Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 57 |
switch ($section) { |
switch ($section) { |
| 58 |
case 'user/'. arg(1) .'/openid': |
case 'user/'. arg(1) .'/openid': |
| 59 |
return t('You may login to this site using an OpenID. You may add your OpenId URLs below, and also see a list of any OpenIDs which have already been added.'); |
return t('You may login to this site using an OpenID. You may add your OpenId URLs below, and also see a list of any OpenIDs which have already been added.'); |
| 60 |
|
case 'admin/help#openid': |
| 61 |
|
$output = '<p>'. t('OpenID is a secure way to use one user ID and password to log in to many web sites without special software, giving the same password to each site, or losing control over which information is shared with each site that you visit.') .'</p>'; |
| 62 |
|
$output .= '<p>'. t('Users can create accounts using their OpenID, assign one or more OpenIDs to an existing account, and log in using an OpenID. This lowers the barrier to registration, which is good for the site, and offers convenience and security to the users. Logging in via OpenID is far more secure than cross-site logins using drupal.module.') .'</p>'; |
| 63 |
|
$output .= '<p>'. t('More information on OpenID is available at <a href="@url">OpenID.net</a>', array('@url' => url('http://openid.net'))) .'</p>'; |
| 64 |
|
return $output; |
| 65 |
} |
} |
| 66 |
} |
} |
| 67 |
|
|
| 99 |
$form['openid_url'] = array( |
$form['openid_url'] = array( |
| 100 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 101 |
'#title' => t('Log in using OpenID'), |
'#title' => t('Log in using OpenID'), |
|
'#default_value' => '', |
|
| 102 |
'#size' => ($form_id == 'user_login') ? 58 : 13, |
'#size' => ($form_id == 'user_login') ? 58 : 13, |
| 103 |
'#maxlength' => 255, |
'#maxlength' => 255, |
| 104 |
'#weight' => -1, |
'#weight' => -1, |
| 106 |
'#prefix' => '<div id="edit-openid-url-wrapper">', |
'#prefix' => '<div id="edit-openid-url-wrapper">', |
| 107 |
'#suffix' => '</div>' |
'#suffix' => '</div>' |
| 108 |
); |
); |
| 109 |
$form['openid.return_to'] = array('#type' => 'hidden', '#value' => url('openid/authenticate', NULL, NULL, TRUE)); |
$form['openid.return_to'] = array('#type' => 'hidden', '#value' => url('openid/authenticate', drupal_get_destination(), NULL, TRUE)); |
| 110 |
$form['name']['#prefix'] = '<div id="edit-name-wrapper">'; |
$form['name']['#prefix'] = '<div id="edit-name-wrapper">'; |
| 111 |
$form['name']['#suffix'] = '</div>'; |
$form['name']['#suffix'] = '</div>'; |
| 112 |
$form['pass']['#prefix'] = '<div id="edit-pass-wrapper">'; |
$form['pass']['#prefix'] = '<div id="edit-pass-wrapper">'; |
| 223 |
|
|
| 224 |
$services = openid_discovery($claimed_id); |
$services = openid_discovery($claimed_id); |
| 225 |
if (count($services) == 0) { |
if (count($services) == 0) { |
| 226 |
drupal_set_message(t('Unable authenticate. OpenID Discovery failed.'), 'error'); |
form_set_error('openid_url', t('Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.')); |
| 227 |
return; |
return; |
| 228 |
} |
} |
| 229 |
|
|
| 360 |
} |
} |
| 361 |
|
|
| 362 |
/** |
/** |
| 363 |
* Attempt to create a shared secrete with the OpenID Provider. |
* Attempt to create a shared secret with the OpenID Provider. |
| 364 |
* |
* |
| 365 |
* @param $op_endpoint URL of the OpenID Provider endpoint. |
* @param $op_endpoint URL of the OpenID Provider endpoint. |
| 366 |
* |
* |
| 431 |
drupal_set_message(t('You must validate your email address for this account before logging in via OpenID')); |
drupal_set_message(t('You must validate your email address for this account before logging in via OpenID')); |
| 432 |
} |
} |
| 433 |
} |
} |
| 434 |
else { |
elseif (variable_get('user_register', 1)) { |
| 435 |
// Register new user |
// Register new user |
| 436 |
$form = drupal_retrieve_form('user_register'); |
$form = drupal_retrieve_form('user_register'); |
| 437 |
$edit['name'] = (empty($response['openid.sreg.nickname'])) ? $identity : $response['openid.sreg.nickname']; |
$edit['name'] = (empty($response['openid.sreg.nickname'])) ? $identity : $response['openid.sreg.nickname']; |
| 461 |
user_login_submit('user_login', array()); |
user_login_submit('user_login', array()); |
| 462 |
} |
} |
| 463 |
} |
} |
| 464 |
|
else { |
| 465 |
|
drupal_set_message(t('Only site administrators can create new user accounts.'), 'error'); |
| 466 |
|
} |
| 467 |
drupal_goto(); |
drupal_goto(); |
| 468 |
} |
} |
| 469 |
|
|
| 540 |
if ($self_sig == $response['openid.sig']) { |
if ($self_sig == $response['openid.sig']) { |
| 541 |
$valid = TRUE; |
$valid = TRUE; |
| 542 |
} |
} |
|
else { |
|
|
$valid = FALSE; |
|
|
} |
|
| 543 |
} |
} |
| 544 |
else { |
else { |
| 545 |
$request = $response; |
$request = $response; |
| 547 |
$message = _openid_create_message($request); |
$message = _openid_create_message($request); |
| 548 |
$headers = array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8'); |
$headers = array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8'); |
| 549 |
$result = drupal_http_request($op_endpoint, $headers, 'POST', _openid_encode_message($message)); |
$result = drupal_http_request($op_endpoint, $headers, 'POST', _openid_encode_message($message)); |
| 550 |
$response = _openid_parse_message($result->data); |
if (!isset($result->error)) { |
| 551 |
if (strtolower(trim($response['is_valid'])) == 'true') { |
$response = _openid_parse_message($result->data); |
| 552 |
$valid = TRUE; |
if (strtolower(trim($response['is_valid'])) == 'true') { |
| 553 |
} |
$valid = TRUE; |
| 554 |
else { |
} |
|
$valid = FALSE; |
|
| 555 |
} |
} |
| 556 |
} |
} |
| 557 |
|
|