[TASK] Cleanup phpDoc to match CGL
[Packages/TYPO3.CMS.git] / typo3 / sysext / openid / Classes / OpenidEid.php
1 <?php
2 namespace TYPO3\CMS\Openid;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Core\Utility\HttpUtility;
19
20 /**
21 * This class is the OpenID return script for the TYPO3 Frontend.
22 *
23 * @author Dmitry Dulepov <dmitry@typo3.org>
24 */
25 class OpenidEid {
26
27 /**
28 * Processes eID request.
29 *
30 * @return void
31 */
32 public function main() {
33 // Due to the nature of OpenID (redrections, etc) we need to force user
34 // session fetching if there is no session around. This ensures that
35 // our service is called even if there is no login data in the request.
36 // Inside the service we will process OpenID response and authenticate
37 // the user.
38 $GLOBALS['TYPO3_CONF_VARS']['SVCONF']['auth']['FE_fetchUserIfNoSession'] = TRUE;
39 // Initialize Frontend user
40 \TYPO3\CMS\Frontend\Utility\EidUtility::initFeUser();
41 // Redirect to the original location in any case (authenticated or not)
42 @ob_end_clean();
43 if ($this->getSignature(GeneralUtility::_GP('tx_openid_location')) === GeneralUtility::_GP('tx_openid_location_signature')) {
44 HttpUtility::redirect(GeneralUtility::_GP('tx_openid_location'), HttpUtility::HTTP_STATUS_303);
45 }
46 }
47
48 /**
49 * Signs a GET parameter.
50 *
51 * @param string $parameter
52 * @return string
53 */
54 protected function getSignature($parameter) {
55 return GeneralUtility::hmac($parameter, 'openid');
56 }
57 }