[CLEANUP] Improve code quality in openid
[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 * @author Dmitry Dulepov <dmitry@typo3.org>
25 */
26 class OpenidEid {
27
28 /**
29 * Processes eID request.
30 *
31 * @return void
32 */
33 public function main() {
34 // Due to the nature of OpenID (redrections, etc) we need to force user
35 // session fetching if there is no session around. This ensures that
36 // our service is called even if there is no login data in the request.
37 // Inside the service we will process OpenID response and authenticate
38 // the user.
39 $GLOBALS['TYPO3_CONF_VARS']['SVCONF']['auth']['FE_fetchUserIfNoSession'] = TRUE;
40 // Initialize Frontend user
41 EidUtility::initFeUser();
42 // Redirect to the original location in any case (authenticated or not)
43 @ob_end_clean();
44
45 $location = GeneralUtility::_GP('tx_openid_location');
46 $signature = GeneralUtility::hmac($location, 'openid');
47 if ($signature === GeneralUtility::_GP('tx_openid_location_signature')) {
48 HttpUtility::redirect($location, HttpUtility::HTTP_STATUS_303);
49 }
50 }
51
52 }