示例#1
0
 /**
  * Checks RSA configuration and creates warnings if necessary.
  *
  * @param array $warnings Warnings
  * @return void
  * @see 	t3lib_BEfunc::displayWarningMessages()
  */
 public function displayWarningMessages_postProcess(array &$warnings)
 {
     $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
     if ($backend instanceof \TYPO3\CMS\Rsaauth\Backend\CommandLineBackend) {
         // Not using the PHP extension!
         $warnings['rsaauth_cmdline'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_using_cmdline');
         // Check the path
         $extconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rsaauth']);
         $path = trim($extconf['temporaryDirectory']);
         if ($path == '') {
             // Path is empty
             $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_empty_directory');
         } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($path)) {
             // Path is not absolute
             $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_absolute');
         } elseif (!@is_dir($path)) {
             // Path does not represent a directory
             $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_exist');
         } elseif (!@is_writable($path)) {
             // Directory is not writable
             $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_writable');
         } elseif (substr($path, 0, strlen(PATH_site)) == PATH_site) {
             // Directory is inside the site root
             $warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_inside_siteroot');
         }
     }
 }
 /**
  * Hooks to the felogin extension to provide additional code for FE login
  *
  * @return array 0 => onSubmit function, 1 => extra fields and required files
  */
 public function loginFormHook()
 {
     $result = array(0 => '', 1 => '');
     if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel']) === 'rsa') {
         $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
         if ($backend) {
             $result[0] = 'tx_rsaauth_feencrypt(this);';
             $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'resources/';
             $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'rsaauth_min.js');
             foreach ($files as $file) {
                 $result[1] .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
             }
             // Generate a new key pair
             $keyPair = $backend->createNewKeyPair();
             // Save private key
             $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage();
             /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */
             $storage->put($keyPair->getPrivateKey());
             // Add RSA hidden fields
             $result[1] .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />';
             $result[1] .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />';
         }
     }
     return $result;
 }
 /**
  * Gets RSA Public Key.
  *
  * @return Keypair|NULL
  */
 public function getRsaPublicKey()
 {
     $keyPair = null;
     $backend = Backend\BackendFactory::getBackend();
     if ($backend !== null) {
         $keyPair = $backend->createNewKeyPair();
         $storage = Storage\StorageFactory::getStorage();
         $storage->put($keyPair->getPrivateKey());
         session_commit();
     }
     return $keyPair;
 }
示例#4
0
 /**
  * Gets RSA Public Key.
  *
  * @param array $parameters Parameters (not used)
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $parent The calling parent AJAX object
  * @return void
  */
 public function getRsaPublicKey(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $parent)
 {
     $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
     if ($backend !== NULL) {
         $keyPair = $backend->createNewKeyPair();
         $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage();
         $storage->put($keyPair->getPrivateKey());
         session_commit();
         $parent->addContent('publicKeyModulus', $keyPair->getPublicKeyModulus());
         $parent->addContent('exponent', sprintf('%x', $keyPair->getExponent()));
         $parent->setContentFormat('json');
     } else {
         $parent->setError('No OpenSSL backend could be obtained for rsaauth.');
     }
 }
 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function processRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     /** @var \TYPO3\CMS\Rsaauth\Backend\AbstractBackend $backend */
     $backend = BackendFactory::getBackend();
     if ($backend === null) {
         // add a HTTP 500 error code, if an error occurred
         return $response->withStatus(500);
     }
     $keyPair = $backend->createNewKeyPair();
     $storage = StorageFactory::getStorage();
     $storage->put($keyPair->getPrivateKey());
     session_commit();
     $content = $keyPair->getPublicKeyModulus() . ':' . sprintf('%x', $keyPair->getExponent()) . ':';
     $response->getBody()->write($content);
     return $response;
 }
示例#6
0
 /**
  * Hooks to the felogin extension to provide additional code for FE login
  *
  * @return array 0 => onSubmit function, 1 => extra fields and required files
  */
 public function loginFormHook()
 {
     $result = array(0 => '', 1 => '');
     if (trim($GLOBALS['TYPO3_CONF_VARS']['FE']['loginSecurityLevel']) === 'rsa') {
         $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
         if ($backend) {
             $result[0] = 'return TYPO3FrontendLoginFormRsaEncryption.submitForm(this, TYPO3FrontendLoginFormRsaEncryptionPublicKeyUrl);';
             $javascriptPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('rsaauth') . 'Resources/Public/JavaScript/';
             $files = array('jsbn/jsbn.js', 'jsbn/prng4.js', 'jsbn/rng.js', 'jsbn/rsa.js', 'jsbn/base64.js', 'FrontendLoginFormRsaEncryption.min.js');
             $eIdUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($GLOBALS['TSFE']->absRefPrefix . 'index.php?eID=FrontendLoginRsaPublicKey');
             $additionalHeader = '<script type="text/javascript">var TYPO3FrontendLoginFormRsaEncryptionPublicKeyUrl = ' . $eIdUrl . ';</script>';
             foreach ($files as $file) {
                 $additionalHeader .= '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $javascriptPath . $file . '"></script>';
             }
             $GLOBALS['TSFE']->additionalHeaderData['rsaauth_js'] = $additionalHeader;
         }
     }
     return $result;
 }
示例#7
0
 /**
  * Adds RSA-specific JavaScript and returns a form tag
  *
  * @return string Form tag
  */
 public function getLoginFormTag(array $params, \TYPO3\CMS\Backend\Controller\LoginController &$pObj)
 {
     $form = NULL;
     if ($pObj->loginSecurityLevel == 'rsa') {
         // If we can get the backend, we can proceed
         $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
         if (!is_null($backend)) {
             // Add form tag
             $form = '<form action="index.php" method="post" name="loginform" onsubmit="tx_rsaauth_encrypt();">';
             // Generate a new key pair
             $keyPair = $backend->createNewKeyPair();
             // Save private key
             $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage();
             /** @var $storage \TYPO3\CMS\Rsaauth\Storage\AbstractStorage */
             $storage->put($keyPair->getPrivateKey());
             // Add RSA hidden fields
             $form .= '<input type="hidden" id="rsa_n" name="n" value="' . htmlspecialchars($keyPair->getPublicKeyModulus()) . '" />';
             $form .= '<input type="hidden" id="rsa_e" name="e" value="' . sprintf('%x', $keyPair->getExponent()) . '" />';
         } else {
             throw new \TYPO3\CMS\Core\Error\Exception('No OpenSSL backend could be obtained for rsaauth.', 1318283565);
         }
     }
     return $form;
 }
<?php

defined('TYPO3_MODE') or die;
/**
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */
/** @var \TYPO3\CMS\Rsaauth\Backend\AbstractBackend $backend */
$backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
if ($backend !== NULL) {
    $keyPair = $backend->createNewKeyPair();
    $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage();
    $storage->put($keyPair->getPrivateKey());
    session_commit();
    echo $keyPair->getPublicKeyModulus() . ':' . sprintf('%x', $keyPair->getExponent()) . ':';
}
示例#9
0
 /**
  * Initializes the service.
  *
  * @return bool
  */
 public function init()
 {
     $available = parent::init();
     if ($available) {
         // Get the backend
         $this->backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
         if ($this->backend === NULL) {
             $available = FALSE;
         }
     }
     return $available;
 }
示例#10
0
 /**
  * Rsa is available if loginSecurityLevel is set and rsa backend is working.
  *
  * @return boolean
  */
 protected function isRsaAvailable()
 {
     return trim($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) === 'rsa' && \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend() !== NULL;
 }
 /**
  * @return Backend\AbstractBackend|NULL
  */
 protected function getBackend()
 {
     if ($this->backend === null) {
         $this->backend = Backend\BackendFactory::getBackend();
     }
     return $this->backend;
 }