Пример #1
0
 function install()
 {
     if (self::$key === null) {
         $cryptokey = \Defuse\Crypto\Key::createNewRandomKey();
         self::$key = $cryptokey->saveToAsciiSafeString();
     }
     $authconfig = $this->getConfigIni()->getValue('auth', 'coordplugins');
     $authconfigMaster = $this->getLocalConfigIni()->getValue('auth', 'coordplugins');
     $forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc'));
     if (!$authconfig || $forWS && $authconfig == $authconfigMaster) {
         if ($forWS) {
             $pluginIni = 'authsw.coord.ini.php';
         } else {
             $pluginIni = 'auth.coord.ini.php';
         }
         $authconfig = dirname($this->entryPoint->getConfigFile()) . '/' . $pluginIni;
         if ($this->firstExec('auth:' . $authconfig)) {
             // no configuration, let's install the plugin for the entry point
             $this->config->setValue('auth', $authconfig, 'coordplugins');
             if (!file_exists(jApp::configPath($authconfig))) {
                 $this->copyFile('var/config/' . $pluginIni, jApp::configPath($authconfig));
             }
         }
     }
     $this->getLocalConfigIni()->setValue('persistant_encryption_key', self::$key, 'coordplugin_auth');
 }
Пример #2
0
 function install()
 {
     if (self::$key === null) {
         self::$key = jAuth::getRandomPassword(30, true);
     }
     $authconfig = $this->config->getValue('auth', 'coordplugins');
     $authconfigMaster = $this->config->getValue('auth', 'coordplugins', null, true);
     $forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc'));
     if (!$authconfig || $forWS && $authconfig == $authconfigMaster) {
         if ($forWS) {
             $pluginIni = 'authsw.coord.ini.php';
         } else {
             $pluginIni = 'auth.coord.ini.php';
         }
         $authconfig = dirname($this->entryPoint->configFile) . '/' . $pluginIni;
         if ($this->firstExec('auth:' . $authconfig)) {
             // no configuration, let's install the plugin for the entry point
             $this->config->setValue('auth', $authconfig, 'coordplugins');
             if (!file_exists(jApp::configPath($authconfig))) {
                 $this->copyFile('var/config/' . $pluginIni, jApp::configPath($authconfig));
             }
         }
     }
     $localConfigIni = $this->entryPoint->localConfigIni;
     $key = $localConfigIni->getValue('persistant_crypt_key', 'coordplugin_auth');
     if ($key === 'exampleOfCryptKey' || $key == '') {
         $localConfigIni->getMaster()->setValue('persistant_crypt_key', self::$key, 'coordplugin_auth');
     }
 }