2011-06-23 15:04:32 +00:00
|
|
|
<?php
|
|
|
|
|
2011-06-23 16:18:48 +00:00
|
|
|
//check if curl extension installed
|
|
|
|
if (!in_array ('curl', get_loaded_extensions())){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-04 16:49:29 +00:00
|
|
|
$userName='';
|
|
|
|
if(strpos($_SERVER["REQUEST_URI"],'?') and !strpos($_SERVER["REQUEST_URI"],'=')){
|
|
|
|
if(strpos($_SERVER["REQUEST_URI"],'/?')){
|
|
|
|
$userName=substr($_SERVER["REQUEST_URI"],strpos($_SERVER["REQUEST_URI"],'/?')+2);
|
|
|
|
}elseif(strpos($_SERVER["REQUEST_URI"],'.php?')){
|
|
|
|
$userName=substr($_SERVER["REQUEST_URI"],strpos($_SERVER["REQUEST_URI"],'.php?')+5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-01 21:19:39 +00:00
|
|
|
OCP\Util::addHeader('link',array('rel'=>'openid.server', 'href'=>OCP\Util::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName));
|
|
|
|
OCP\Util::addHeader('link',array('rel'=>'openid.delegate', 'href'=>OCP\Util::linkToAbsolute( "user_openid", "user.php" ).'/'.$userName));
|
2011-06-24 20:07:26 +00:00
|
|
|
|
2011-08-08 21:32:54 +00:00
|
|
|
OC_APP::registerPersonal('user_openid','settings');
|
|
|
|
|
2011-06-23 15:04:32 +00:00
|
|
|
require_once 'apps/user_openid/user_openid.php';
|
|
|
|
|
|
|
|
//active the openid backend
|
2011-07-29 19:36:03 +00:00
|
|
|
OC_User::useBackend('openid');
|
2011-06-23 15:04:32 +00:00
|
|
|
|
|
|
|
//check for results from openid requests
|
|
|
|
if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){
|
2012-05-01 15:38:27 +00:00
|
|
|
OCP\Util::writeLog('user_openid','openid retured',OCP\Util::DEBUG);
|
2011-06-23 15:04:32 +00:00
|
|
|
$openid = new SimpleOpenID;
|
|
|
|
$openid->SetIdentity($_GET['openid_identity']);
|
|
|
|
$openid_validation_result = $openid->ValidateWithServer();
|
|
|
|
if ($openid_validation_result == true){ // OK HERE KEY IS VALID
|
2012-05-01 15:38:27 +00:00
|
|
|
OCP\Util::writeLog('user_openid','auth sucessfull',OCP\Util::DEBUG);
|
2011-06-23 15:04:32 +00:00
|
|
|
$identity=$openid->GetIdentity();
|
2012-05-01 15:38:27 +00:00
|
|
|
OCP\Util::writeLog('user_openid','auth as '.$identity,OCP\Util::DEBUG);
|
2011-06-23 15:04:32 +00:00
|
|
|
$user=OC_USER_OPENID::findUserForIdentity($identity);
|
|
|
|
if($user){
|
|
|
|
$_SESSION['user_id']=$user;
|
2011-09-18 17:37:54 +00:00
|
|
|
header("Location: ".OC::$WEBROOT);
|
2011-06-23 15:04:32 +00:00
|
|
|
}
|
|
|
|
}else if($openid->IsError() == true){ // ON THE WAY, WE GOT SOME ERROR
|
|
|
|
$error = $openid->GetError();
|
2012-05-01 15:38:27 +00:00
|
|
|
OCP\Util::writeLog('user_openid','ERROR CODE: '. $error['code'],OCP\Util::ERROR);
|
|
|
|
OCP\Util::writeLog('user_openid','ERROR DESCRIPTION: '. $error['description'],OCP\Util::ERROR);
|
2011-06-23 15:04:32 +00:00
|
|
|
}else{ // Signature Verification Failed
|
2012-05-01 15:38:27 +00:00
|
|
|
OCP\Util::writeLog('user_openid','INVALID AUTHORIZATION',OCP\Util::ERROR);
|
2011-06-23 15:04:32 +00:00
|
|
|
}
|
|
|
|
}else if (isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'cancel'){ // User Canceled your Request
|
2012-05-01 15:38:27 +00:00
|
|
|
OCP\Util::writeLog('user_openid','USER CANCELED REQUEST',OCP\Util::DEBUG);
|
2011-06-23 15:04:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|