7ac34354bde3594714c9233a9469d3b8f78408e1
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / Classes / Hook / FrontendLoginHook.php
1 <?php
2 namespace TYPO3\CMS\Rsaauth\Hook;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009-2013 Dmitry Dulepov <dmitry@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * This class contains a hook to implement RSA authentication for the TYPO3
28 * Frontend. Warning: felogin must be USER_INT for this to work!
29 *
30 * @author Dmitry Dulepov <dmitry@typo3.org>
31 */
32 class FrontendLoginHook {
33
34 /**
35 * Hooks to the felogin extension to provide additional code for FE login
36 *
37 * @return array 0 => onSubmit function, 1 => extra fields and required files
38 */
39 public function loginFormHook() {
40 $result = array(0 => '', 1 => '');
41 if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel']) === 'rsa') {
42 $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
43 if ($backend) {
44 $result[0] = 'return TYPO3FrontendLoginFormRsaEncryption.submitForm(this, TYPO3FrontendLoginFormRsaEncryptionPublicKeyUrl);';
45 $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'resources/';
46 $files = array(
47 'jsbn/jsbn.js',
48 'jsbn/prng4.js',
49 'jsbn/rng.js',
50 'jsbn/rsa.js',
51 'jsbn/base64.js',
52 'FrontendLoginFormRsaEncryption.min.js'
53 );
54 $eIdUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($GLOBALS['TSFE']->absRefPrefix . 'index.php?eID=FrontendLoginRsaPublicKey');
55 $additionalHeader = '<script type="text/javascript">var TYPO3FrontendLoginFormRsaEncryptionPublicKeyUrl = ' . $eIdUrl . ';</script>';
56 foreach ($files as $file) {
57 $additionalHeader .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
58 }
59 $GLOBALS['TSFE']->additionalHeaderData['rsaauth_js'] = $additionalHeader;
60 }
61 }
62 return $result;
63 }
64
65 }