TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Openid\OpenidService Class Reference
Inheritance diagram for TYPO3\CMS\Openid\OpenidService:
TYPO3\CMS\Core\Service\AbstractService tx_openid_sv1 TYPO3\CMS\Openid\Wizard

Public Member Functions

 __construct ()
 
 init ()
 
 initAuth ($subType, array $loginData, array $authenticationInformation, AbstractUserAuthentication &$parentObject)
 
 processLoginData (array &$loginData, $passwordTransmissionStrategy)
 
 getUser ()
 
 authUser (array $userRecord)
 
- Public Member Functions inherited from TYPO3\CMS\Core\Service\AbstractService
 getServiceInfo ()
 
 getServiceKey ()
 
 getServiceTitle ()
 
 getServiceOption ($optionName, $defaultValue='', $includeDefaultConfig=TRUE)
 
 devLog ($msg, $severity=0, $dataVar=FALSE)
 
 errorPush ($errNum=T3_ERR_SV_GENERAL, $errMsg='Unspecified error occurred')
 
 errorPull ()
 
 getLastError ()
 
 getLastErrorMsg ()
 
 getErrorMsgArray ()
 
 getLastErrorArray ()
 
 resetErrors ()
 
 checkExec ($progList)
 
 deactivateService ()
 
 checkInputFile ($absFile)
 
 readFile ($absFile, $length=0)
 
 writeFile ($content, $absFile='')
 
 tempFile ($filePrefix)
 
 registerTempFile ($absFile)
 
 unlinkTempFiles ()
 
 setInput ($content, $type='')
 
 setInputFile ($absFile, $type='')
 
 getInput ()
 
 getInputFile ($createFile='')
 
 setOutputFile ($absFile)
 
 getOutput ()
 
 getOutputFile ($absFile='')
 
 init ()
 
 reset ()
 
 __destruct ()
 

Public Attributes

 $extKey = 'openid'
 
- Public Attributes inherited from TYPO3\CMS\Core\Service\AbstractService
 $info = array()
 
 $error = array()
 
 $writeDevLog = FALSE
 
 $out = ''
 
 $inputFile = ''
 
 $inputContent = ''
 
 $inputType = ''
 
 $outputFile = ''
 
 $tempFiles = array()
 

Protected Member Functions

 injectDatabaseConnection (\TYPO3\CMS\Core\Database\DatabaseConnection $databaseConnection=NULL)
 
 includePHPOpenIDLibrary ()
 
 getUserRecord ($openIDIdentifier)
 
 getOpenIDConsumer ()
 
 sendOpenIDRequest ($openIDIdentifier)
 
 getReturnURL ($claimedIdentifier)
 
 getSignature ($parameter)
 
 normalizeOpenID ($openIDIdentifier)
 
 getBackPath ()
 
 getFinalOpenIDIdentifier ()
 
 getSignedClaimedOpenIDIdentifier ()
 
 getSignedParameter ($parameterName)
 
 writeLog ($message)
 

Protected Attributes

 $loginData = array()
 
 $authenticationInformation = array()
 
 $openIDResponse = NULL
 
 $parentObject
 
 $databaseConnection
 
- Protected Attributes inherited from TYPO3\CMS\Core\Service\AbstractService
 $shutdownRegistry = array()
 
 $prefixId = ''
 

Static Protected Attributes

static $openIDLibrariesIncluded = FALSE
 

Detailed Description

Service "OpenID Authentication" for the "openid" extension.

Author
Dmitry Dulepov dmitr.nosp@m.y@ty.nosp@m.po3.o.nosp@m.rg

Definition at line 27 of file OpenidService.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Openid\OpenidService::__construct ( )

Contructs the OpenID authentication service.

Definition at line 73 of file OpenidService.php.

References $GLOBALS, and TYPO3\CMS\Openid\OpenidService\injectDatabaseConnection().

Member Function Documentation

◆ authUser()

TYPO3\CMS\Openid\OpenidService::authUser ( array  $userRecord)

Authenticates user using OpenID.

Parameters
array$userRecordUser record
Returns
integer Code that shows if user is really authenticated.

Definition at line 217 of file OpenidService.php.

References $result, Auth_OpenID_SUCCESS, and TYPO3\CMS\Openid\OpenidService\writeLog().

◆ getBackPath()

TYPO3\CMS\Openid\OpenidService::getBackPath ( )
protected

Calculates the path to the TYPO3 directory from the current directory

Returns
string

Definition at line 481 of file OpenidService.php.

References TYPO3\CMS\Core\Utility\ExtensionManagementUtility\siteRelPath().

Referenced by TYPO3\CMS\Openid\OpenidService\getUser().

◆ getFinalOpenIDIdentifier()

TYPO3\CMS\Openid\OpenidService::getFinalOpenIDIdentifier ( )
protected

◆ getOpenIDConsumer()

TYPO3\CMS\Openid\OpenidService::getOpenIDConsumer ( )
protected

Creates OpenID Consumer object with a TYPO3-specific store. This function is almost identical to the example from the PHP OpenID library.

Returns
Consumer instance

Definition at line 317 of file OpenidService.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Openid\OpenidService\initAuth(), TYPO3\CMS\Openid\Wizard\main(), and TYPO3\CMS\Openid\OpenidService\sendOpenIDRequest().

◆ getReturnURL()

TYPO3\CMS\Openid\OpenidService::getReturnURL (   $claimedIdentifier)
protected

Creates return URL for the OpenID server. When a user is authenticated by the OpenID server, the user will be sent to this URL to complete authentication process with the current site. We send it to our script.

Parameters
string$claimedIdentifierThe OpenID identifier for discovery and auth request
Returns
string Return URL

Definition at line 395 of file OpenidService.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\_GP(), TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), TYPO3\CMS\Openid\OpenidService\getSignature(), and TYPO3\CMS\Core\Utility\GeneralUtility\locationHeaderUrl().

Referenced by TYPO3\CMS\Openid\OpenidService\initAuth(), and TYPO3\CMS\Openid\OpenidService\sendOpenIDRequest().

◆ getSignature()

TYPO3\CMS\Openid\OpenidService::getSignature (   $parameter)
protected

Signs a GET parameter.

Parameters
string$parameter
Returns
string

Definition at line 425 of file OpenidService.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\hmac().

Referenced by TYPO3\CMS\Openid\OpenidService\getReturnURL(), and TYPO3\CMS\Openid\OpenidService\getSignedClaimedOpenIDIdentifier().

◆ getSignedClaimedOpenIDIdentifier()

TYPO3\CMS\Openid\OpenidService::getSignedClaimedOpenIDIdentifier ( )
protected

Gets the signed OpenID that was sent back to this service.

Returns
string The signed OpenID, if signature did not match this is empty

Definition at line 509 of file OpenidService.php.

References $result, TYPO3\CMS\Core\Utility\GeneralUtility\_GP(), and TYPO3\CMS\Openid\OpenidService\getSignature().

Referenced by TYPO3\CMS\Openid\OpenidService\getFinalOpenIDIdentifier().

◆ getSignedParameter()

TYPO3\CMS\Openid\OpenidService::getSignedParameter (   $parameterName)
protected

Obtains a value of the parameter if it is signed. If not signed, then empty string is returned.

Parameters
string$parameterNameMust start with 'openid_'
Returns
string

Definition at line 525 of file OpenidService.php.

References $result, TYPO3\CMS\Core\Utility\GeneralUtility\_GP(), and TYPO3\CMS\Core\Utility\GeneralUtility\inList().

Referenced by TYPO3\CMS\Openid\OpenidService\getFinalOpenIDIdentifier(), and TYPO3\CMS\Openid\Wizard\getReturnUrl().

◆ getUser()

TYPO3\CMS\Openid\OpenidService::getUser ( )

This function returns the user record back to the AbstractUserAuthentication. It does not mean that user is authenticated, it means only that user is found. This function makes sure that user cannot be authenticated by any other service if user tries to use OpenID to authenticate.

Returns
mixed User record (content of fe_users/be_users as appropriate for the current mode)

Definition at line 177 of file OpenidService.php.

References $GLOBALS, Auth_OpenID_SUCCESS, TYPO3\CMS\Openid\OpenidService\getBackPath(), TYPO3\CMS\Openid\OpenidService\getFinalOpenIDIdentifier(), TYPO3\CMS\Core\Utility\GeneralUtility\getRandomHexString(), TYPO3\CMS\Openid\OpenidService\getUserRecord(), TYPO3\CMS\Openid\OpenidService\sendOpenIDRequest(), and TYPO3\CMS\Openid\OpenidService\writeLog().

◆ getUserRecord()

TYPO3\CMS\Openid\OpenidService::getUserRecord (   $openIDIdentifier)
protected

Gets user record for the user with the OpenID provided by the user

Parameters
string$openIDIdentifierOpenID identifier to search for
Returns
array Database fields from the table that corresponds to the current login mode (FE/BE)

Definition at line 283 of file OpenidService.php.

References TYPO3\CMS\Openid\OpenidService\normalizeOpenID(), and TYPO3\CMS\Openid\OpenidService\writeLog().

Referenced by TYPO3\CMS\Openid\OpenidService\getUser().

◆ includePHPOpenIDLibrary()

TYPO3\CMS\Openid\OpenidService::includePHPOpenIDLibrary ( )
protected

◆ init()

TYPO3\CMS\Openid\OpenidService::init ( )

Checks if service is available,. In case of this service we check that prerequesties for "PHP OpenID" libraries are fulfilled:

  • GMP or BCMATH PHP extensions are installed and functional
  • set_include_path() PHP function is available
Returns
boolean TRUE if service is available

Definition at line 100 of file OpenidService.php.

References TYPO3\CMS\Openid\OpenidService\writeLog().

◆ initAuth()

TYPO3\CMS\Openid\OpenidService::initAuth (   $subType,
array  $loginData,
array  $authenticationInformation,
AbstractUserAuthentication $parentObject 
)

Initializes authentication for this service.

Parameters
string$subType,Subtype for authentication (either "getUserFE" or "getUserBE")
array$loginData,Login data submitted by user and preprocessed by AbstractUserAuthentication
array$authenticationInformation,Additional TYPO3 information for authentication services (unused here)
AbstractUserAuthentication$parentObjectCalling object
Returns
void

Definition at line 126 of file OpenidService.php.

References TYPO3\CMS\Openid\OpenidService\$authenticationInformation, TYPO3\CMS\Openid\OpenidService\$loginData, TYPO3\CMS\Openid\OpenidService\$parentObject, TYPO3\CMS\Core\Utility\GeneralUtility\_GP(), TYPO3\CMS\Openid\OpenidService\getOpenIDConsumer(), TYPO3\CMS\Openid\OpenidService\getReturnURL(), and TYPO3\CMS\Openid\OpenidService\includePHPOpenIDLibrary().

◆ injectDatabaseConnection()

TYPO3\CMS\Openid\OpenidService::injectDatabaseConnection ( \TYPO3\CMS\Core\Database\DatabaseConnection  $databaseConnection = NULL)
protected
Parameters
\TYPO3\CMS\Core\Database\DatabaseConnection$databaseConnection

Definition at line 88 of file OpenidService.php.

References TYPO3\CMS\Openid\OpenidService\$databaseConnection, and $GLOBALS.

Referenced by TYPO3\CMS\Openid\OpenidService\__construct().

◆ normalizeOpenID()

TYPO3\CMS\Openid\OpenidService::normalizeOpenID (   $openIDIdentifier)
protected

Implement normalization according to OpenID 2.0 specification See http://openid.net/specs/openid-authentication-2_0.html#normalization

Parameters
string$openIDIdentifierOpenID identifier to normalize
Returns
string Normalized OpenID identifier
Exceptions
Exception

Definition at line 437 of file OpenidService.php.

Referenced by TYPO3\CMS\Openid\OpenidService\getUserRecord(), and TYPO3\CMS\Openid\OpenidService\processLoginData().

◆ processLoginData()

TYPO3\CMS\Openid\OpenidService::processLoginData ( array &  $loginData,
  $passwordTransmissionStrategy 
)

Process the submitted OpenID URL if valid.

Parameters
array$loginDataCredentials that are submitted and potentially modified by other services
string$passwordTransmissionStrategyKeyword of how the password has been hashed or encrypted before submission
Returns
boolean

Definition at line 146 of file OpenidService.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\_POST(), TYPO3\CMS\Openid\OpenidService\normalizeOpenID(), and TYPO3\CMS\Openid\OpenidService\writeLog().

◆ sendOpenIDRequest()

TYPO3\CMS\Openid\OpenidService::sendOpenIDRequest (   $openIDIdentifier)
protected

Sends request to the OpenID server to authenticate the user with the given ID. This function is almost identical to the example from the PHP OpenID library. Due to the OpenID specification we cannot do a slient login. Sometimes we have to redirect to the OpenID provider web site so that user can enter his password there. In this case we will redirect and provide a return adress to the special script inside this directory, which will handle the result appropriately.

This function does not return on success. If it returns, it means something went totally wrong with OpenID.

Parameters
string$openIDIdentifierThe OpenID identifier for discovery and auth request
Returns
void

Definition at line 339 of file OpenidService.php.

References die, TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), TYPO3\CMS\Openid\OpenidService\getOpenIDConsumer(), TYPO3\CMS\Openid\OpenidService\getReturnURL(), TYPO3\CMS\Core\Utility\HttpUtility\HTTP_STATUS_303, TYPO3\CMS\Openid\OpenidService\includePHPOpenIDLibrary(), Auth_OpenID\isFailure(), TYPO3\CMS\Core\Utility\HttpUtility\redirect(), and TYPO3\CMS\Openid\OpenidService\writeLog().

Referenced by TYPO3\CMS\Openid\OpenidService\getUser(), and TYPO3\CMS\Openid\Wizard\main().

◆ writeLog()

TYPO3\CMS\Openid\OpenidService::writeLog (   $message)
protected

Writes log message. Destination log depends on the current system mode. For FE the function writes to the admin panel log. For BE messages are sent to the system log. If developer log is enabled, messages are also sent there.

This function accepts variable number of arguments and can format parameters. The syntax is the same as for sprintf()

Parameters
string$messageMessage to output
Returns
void
See also
GeneralUtility::sysLog()
::setTSlogMessage()

Definition at line 549 of file OpenidService.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\GeneralUtility\devLog(), TYPO3\CMS\Core\Utility\GeneralUtility\SYSLOG_SEVERITY_NOTICE, and TYPO3_MODE.

Referenced by TYPO3\CMS\Openid\OpenidService\authUser(), TYPO3\CMS\Openid\OpenidService\getUser(), TYPO3\CMS\Openid\OpenidService\getUserRecord(), TYPO3\CMS\Openid\OpenidService\includePHPOpenIDLibrary(), TYPO3\CMS\Openid\OpenidService\init(), TYPO3\CMS\Openid\OpenidService\processLoginData(), and TYPO3\CMS\Openid\OpenidService\sendOpenIDRequest().

Member Data Documentation

◆ $authenticationInformation

TYPO3\CMS\Openid\OpenidService::$authenticationInformation = array()
protected

Additional authentication information provided by AbstractUserAuthentication. We use it to decide what database table contains user records.

Definition at line 43 of file OpenidService.php.

Referenced by TYPO3\CMS\Openid\OpenidService\initAuth().

◆ $databaseConnection

TYPO3\CMS\Openid\OpenidService::$databaseConnection
protected

◆ $extKey

TYPO3\CMS\Openid\OpenidService::$extKey = 'openid'

The extension key

Definition at line 32 of file OpenidService.php.

◆ $loginData

TYPO3\CMS\Openid\OpenidService::$loginData = array()
protected

Login data as passed to initAuth()

Definition at line 37 of file OpenidService.php.

Referenced by TYPO3\CMS\Openid\OpenidService\initAuth().

◆ $openIDLibrariesIncluded

TYPO3\CMS\Openid\OpenidService::$openIDLibrariesIncluded = FALSE
staticprotected

If set to TRUE, than libraries are already included.

Definition at line 68 of file OpenidService.php.

◆ $openIDResponse

TYPO3\CMS\Openid\OpenidService::$openIDResponse = NULL
protected

Definition at line 51 of file OpenidService.php.

◆ $parentObject

TYPO3\CMS\Openid\OpenidService::$parentObject
protected

Definition at line 58 of file OpenidService.php.

Referenced by TYPO3\CMS\Openid\OpenidService\initAuth().