20 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'openid') .
'lib/php-openid/Auth/OpenID/Interface.php';
76 if (!defined(
'Auth_Yadis_CURL_OVERRIDE')) {
77 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'curlUse']) {
78 define(
'Auth_Yadis_CURL_OVERRIDE', TRUE);
102 if (extension_loaded(
'gmp')) {
103 $available = is_callable(
'gmp_init');
104 } elseif (extension_loaded(
'bcmath')) {
105 $available = is_callable(
'bcadd');
107 $this->
writeLog(
'Neither bcmath, nor gmp PHP extension found. OpenID authentication will not be available.');
110 if (!is_callable(
'set_include_path')) {
112 $this->
writeLog(
'set_include_path() PHP function is not available. OpenID authentication is disabled.');
114 return $available ? parent::init() : FALSE;
147 $isProcessed = FALSE;
149 if (empty($loginData[
'uident_text'])) {
152 if (!empty($openIdUrl)) {
155 } elseif (!empty($loginData[
'uname'])) {
159 $loginData[
'uident_openid'] = $this->
normalizeOpenID($loginData[
'uname']);
178 if ($this->loginData[
'status'] !==
'login') {
191 if ($openIDIdentifier) {
193 if (!empty($userRecord) && is_array($userRecord)) {
199 $this->
writeLog(
'User \'%s\' logged in with OpenID \'%s\'', $userRecord[$this->parentObject->formfield_uname], $openIDIdentifier);
201 $this->
writeLog(
'Failed to login user using OpenID \'%s\'', $openIDIdentifier);
205 } elseif (!empty($this->loginData[
'uident_openid'])) {
220 if ($userRecord[
'tx_openid_openid'] !==
'') {
230 $this->
writeLog(
'OpenID authentication failed with code \'%s\'.', $this->openIDResponse->status);
243 if (!self::$openIDLibrariesIncluded) {
245 self::$openIDLibrariesIncluded = TRUE;
247 $oldIncludePath = get_include_path();
249 @set_include_path(($phpOpenIDLibPath . PATH_SEPARATOR . $phpOpenIDLibPath . PATH_SEPARATOR .
'Auth' . PATH_SEPARATOR . $oldIncludePath));
252 if (!defined(
'Auth_OpenID_RAND_SOURCE')) {
253 if (TYPO3_OS ===
'WIN') {
255 define(
'Auth_OpenID_RAND_SOURCE', NULL);
256 } elseif (!is_readable(
'/dev/urandom')) {
257 if (is_readable(
'/dev/random')) {
258 define(
'Auth_OpenID_RAND_SOURCE',
'/dev/random');
260 define(
'Auth_OpenID_RAND_SOURCE', NULL);
265 require_once $phpOpenIDLibPath .
'/Auth/OpenID/Consumer.php';
267 @set_include_path($oldIncludePath);
268 if (!is_array($_SESSION)) {
272 $this->
writeLog(
'Session is initialized');
289 $record = $this->databaseConnection->exec_SELECTgetSingleRow(
291 $this->authenticationInformation[
'db_user'][
'table'],
292 'tx_openid_openid IN (' 293 . $this->databaseConnection->fullQuoteStr($openIDIdentifier, $this->authenticationInformation[
'db_user'][
'table'])
294 .
',' . $this->databaseConnection->fullQuoteStr(rtrim($openIDIdentifier,
'/'),
295 $this->authenticationInformation[
'db_user'][
'table']) .
')' 296 . $this->authenticationInformation[
'db_user'][
'check_pid_clause']
297 . $this->authenticationInformation[
'db_user'][
'enable_clause']
301 $record[
'tx_openid_openid'] = $this->
normalizeOpenID($record[
'tx_openid_openid']);
320 $openIDStore->cleanup();
321 return new \Auth_OpenID_Consumer($openIDStore);
344 $authenticationRequest = $openIDConsumer->begin($openIDIdentifier);
345 if (!$authenticationRequest) {
348 $this->
writeLog(
'Could not create authentication request for OpenID identifier \'%s\'', $openIDIdentifier);
358 if ($authenticationRequest->shouldSendRedirect()) {
359 $redirectURL = $authenticationRequest->redirectURL($trustedRoot, $returnURL);
362 $this->
writeLog(
'Authentication request could not create redirect URL for OpenID identifier \'%s\'', $openIDIdentifier);
371 $formHtml = $authenticationRequest->htmlMarkup($trustedRoot, $returnURL, FALSE, array(
'id' =>
'openid_message'));
376 $this->
writeLog(
'Could not create form markup for OpenID identifier \'%s\'', $openIDIdentifier);
396 if ($this->authenticationInformation[
'loginType'] ===
'FE') {
401 $returnURL =
'index.php?eID=tx_openid&' .
'pid=' . $this->authenticationInformation[
'db_user'][
'checkPidList'] .
'&' .
'logintype=login&';
408 $returnURL = $absoluteSiteURL . TYPO3_mainDir .
'sysext/' . $this->extKey .
'/class.tx_openid_return.php?login_status=login&';
415 $returnURL .=
'tx_openid_location=' . rawurlencode($requestURL) .
'&tx_openid_location_signature=' . $this->
getSignature($requestURL) .
'&tx_openid_mode=finish&tx_openid_claimed=' . rawurlencode($claimedIdentifier) .
'&tx_openid_signature=' . $this->
getSignature($claimedIdentifier);
438 if (empty($openIDIdentifier)) {
439 throw new Exception(
'Empty OpenID Identifier given.', 1381922460);
442 if (strpos($openIDIdentifier,
'#') !== FALSE) {
443 $openIDIdentifier = preg_replace(
'/#.*$/',
'', $openIDIdentifier);
446 if (!preg_match(
'#^https?://#', $openIDIdentifier)) {
447 $escapedIdentifier = $this->databaseConnection->quoteStr($openIDIdentifier, $this->authenticationInformation[
'db_user'][
'table']);
448 $condition =
'tx_openid_openid IN (' 454 $row = $this->databaseConnection->exec_SELECTgetSingleRow(
456 $this->authenticationInformation[
'db_user'][
'table'],
459 if (is_array($row)) {
460 $openIDIdentifier = $row[
'tx_openid_openid'];
465 throw new Exception(
'Trying to authenticate with OpenID but identifier is neither found in a user record nor it is a valid URL.', 1381922465);
470 if (preg_match(
'#^https?://[^/]+$#', $openIDIdentifier)) {
471 $openIDIdentifier .=
'/';
473 return $openIDIdentifier;
483 $segmentCount = count(explode(
'/', $extPath));
484 $path = str_pad(
'', $segmentCount * 3,
'../') . TYPO3_mainDir;
550 if (func_num_args() > 1) {
551 $params = func_get_args();
552 array_shift($params);
553 $message = vsprintf($message, $params);
558 $GLOBALS[
'TT']->setTSlogMessage($message);
560 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'enable_DLOG']) {
processLoginData(array &$loginData, $passwordTransmissionStrategy)
const Auth_OpenID_SUCCESS
static getRandomHexString($count)
getUserRecord($openIDIdentifier)
static devLog($msg, $extKey, $severity=0, $dataVar=FALSE)
$authenticationInformation
static extPath($key, $script='')
static $openIDLibrariesIncluded
sendOpenIDRequest($openIDIdentifier)
static getIndpEnv($getEnvName)
authUser(array $userRecord)
static hmac($input, $additionalSecret='')
getReturnURL($claimedIdentifier)
normalizeOpenID($openIDIdentifier)
static makeInstance($className)
includePHPOpenIDLibrary()
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
injectDatabaseConnection(\TYPO3\CMS\Core\Database\DatabaseConnection $databaseConnection=NULL)
getSignedParameter($parameterName)
static locationHeaderUrl($path)
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
getSignedClaimedOpenIDIdentifier()
static inList($list, $item)
initAuth($subType, array $loginData, array $authenticationInformation, AbstractUserAuthentication &$parentObject)
getFinalOpenIDIdentifier()
const SYSLOG_SEVERITY_NOTICE