[TASK] Make TYPO3 Core PSR-2 standard compliant
[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 use TYPO3\CMS\Frontend\Utility\EidUtility;
20
21 /**
22 * This class is the OpenID return script for the TYPO3 Frontend.
23 */
24 class OpenidEid
25 {
26 /**
27 * Processes eID request.
28 *
29 * @return void
30 */
31 public function main()
32 {
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 EidUtility::initFeUser();
41 // Redirect to the original location in any case (authenticated or not)
42 @ob_end_clean();
43
44 $location = GeneralUtility::_GP('tx_openid_location');
45 $signature = GeneralUtility::hmac($location, 'openid');
46 if ($signature === GeneralUtility::_GP('tx_openid_location_signature')) {
47 HttpUtility::redirect($location, HttpUtility::HTTP_STATUS_303);
48 }
49 }
50 }