Skip to content

Commit

Permalink
Merge branch 'release/v3.0.22' into support/v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
enfoqueNativo committed Apr 6, 2018
2 parents eb46c50 + f38489c commit c421857
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 25 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,12 @@

[CURRENT](https://github.com/SIU-Toba/framework/compare/master...develop)

[3.0.22](https://github.com/SIU-Toba/framework/releases/tag/v3.0.22) (2018-04-05):
- Se actualiza el paquete siu/arai-cli a v2.3.1
- Se corrigen bugs en los hooks de Toba para conectar a Araí
- Se corrige XSS via toba_notificacion (IMPORTANTE!!)
- Se agrega recuperación de exportación de personalización incompleta

[3.0.21](https://github.com/SIU-Toba/framework/releases/tag/v3.0.21) (2018-03-13):
- Se agrega conversion via Psr7\str al mensaje proveniente de un error rest
- Se agrega el metodo toba_auditoria_tablas_postgres::get_tablas_triggers_desactivados (credits FMartinez)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.0.21
3.0.22
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -37,7 +37,7 @@
"siu-toba/services_json": "^1.0.3.3",
"siu/rdi": "~0.9",
"siu/arai-json-migrator" : "~1.0",
"siu/arai-cli" : "~2.2",
"siu/arai-cli" : "^2.3",
"vlucas/phpdotenv": "~2.0",
"ioncube/php-openssl-cryptor": "dev-master"
},
Expand Down
13 changes: 12 additions & 1 deletion php/modelo/personalizacion/toba_personalizacion.php
Expand Up @@ -180,7 +180,11 @@ function exportar()
{
if (!$this->iniciada()) {
throw new toba_error("PERSONALIZACION: Debe iniciar la personalización antes de exportarla");
}
}

if ($this->existe_exportacion_incompleta() && $this->consola->dialogo_simple('La exportación anterior fue incompleta?', 's') == 's' ) {
$this->restaurar_schema_trabajo();
}
$this->crear_directorios();
$this->consola->mensaje('Generando esquema alterno..');
$this->generar_schema_diff(); //Genero el schema con los metadatos originales para hacer el diff
Expand Down Expand Up @@ -531,5 +535,12 @@ protected function restaurar_schema_trabajo()
throw new toba_error_usuario('Hubo un inconveniente al intentar restaurar la instancia de trabajo, revise el log');
}
}

protected function existe_exportacion_incompleta()
{
$schema_o = $this->get_schema_original();
$schema_t = $this->get_schema_personalizacion();
return ($this->get_db()->existe_schema($schema_o) && $this->get_db()->existe_schema($schema_t));
}
}
?>
11 changes: 6 additions & 5 deletions php/nucleo/lib/toba_notificacion.php
Expand Up @@ -105,22 +105,23 @@ function mostrar($incluir_comsumos=true)
toba_js::cargar_consumos_globales(array("basicos/notificacion"));
echo toba_js::abrir();
}
$escapador = toba::escaper();
foreach($this->mensajes as $mensaje){
$texto = toba_parser_ayuda::parsear($mensaje[0]);
$texto = str_replace("'", '"', $texto);
$texto = toba_js::string($texto);
$texto = $escapador ->escapeJs(toba_js::string($texto));
//Mensaje para debug
if (isset($mensaje[2]) && trim($mensaje[2]) != '') {
$texto_debug = toba_parser_ayuda::parsear($mensaje[2]);
$texto_debug = str_replace("'", '"', $texto_debug);
$texto_debug = toba_js::string($texto_debug);
echo "notificacion.agregar('$texto' + '\\n', '{$mensaje[1]}', undefined, '$texto_debug');\n";
$texto_debug = $escapador->escapeJs(toba_js::string($texto_debug));
echo "notificacion.agregar('$texto' + '\\n', '".$escapador->escapeJs($mensaje[1])."', undefined, '$texto_debug');\n";
}else{
echo "notificacion.agregar('$texto' + '\\n', '{$mensaje[1]}');\n";
echo "notificacion.agregar('$texto' + '\\n', '".$escapador->escapeJs($mensaje[1])."');\n";
}
}
if (isset($this->titulo)) {
echo "notificacion.set_titulo_ventana('{$this->titulo}');\n";
echo "notificacion.set_titulo_ventana('". $escapador->escapeJs($this->titulo)."');\n";
}
echo "notificacion.mostrar();\n";
if ($incluir_comsumos) {
Expand Down
86 changes: 69 additions & 17 deletions src/SIUToba/Arai/RegistryHooksProyectoToba.php
Expand Up @@ -188,24 +188,31 @@ protected function postConsumeApp(Consumption $feature)

protected function postConsumeApi(Consumption $feature)
{
$cant = count($feature->getProviders());
echo "Detectando proveedores de api '{$feature->getName()}': {$cant}\n";

$providers = $feature->getProviders();
if (empty($providers)) return; //Nada para configurar


/** @var Provision */
$optionsFijas = $feature->getOptions();
$provider = current($providers); //Asume primer IDP que encuentra!

echo "Procesando proveedor '{$provider->getName()}': ";

if ($provider->getEndpoint() == '') {
//No configura APIs sin URL
echo "no posee configurado 'endpoint'\n";
return;
}

if (! isset($optionsFijas['toba-rest'])) {
echo "No se pudo configurar la feature '".$provider->getName()."', falta setearle los identificadores de los accesos REST en el campo 'toba-rest'\n";
echo "falta setearle los identificadores de los accesos REST en el campo 'toba-rest'\n";
return;
}
foreach ($optionsFijas['toba-rest'] as $acceso) {
if (! isset($acceso['rest-id'])) {
echo "No se pudo configurar la feature '".$provider->getName()."', falta setearle el identificador del acceso REST en el campo 'toba-rest.rest-id'\n";
echo "falta setearle el identificador del acceso REST en el campo 'toba-rest.rest-id'\n";
break;
}

Expand All @@ -218,13 +225,18 @@ protected function postConsumeApi(Consumption $feature)
$iniInstalacion = new \toba_ini($this->instalacion->archivo_info_basica());
$iniInstalacion->agregar_entrada("vincula_arai_usuarios", "1");
$iniInstalacion->guardar();

echo "Activando vínculo entre 'toba_usuarios' y 'Araí' para la gestión de cuentas\n";
}
}



protected function postConsumeService(Consumption $feature)
{
$cant = count($feature->getProviders());
echo "Detectando proveedores de servicio '{$feature->getName()}': {$cant}\n";

if ($feature->getName() == "service:siu/sso-saml-idp") {
$this->postConsumeSamlIdp($feature);
}
Expand All @@ -238,9 +250,13 @@ protected function postConsumeSamlIdp(Consumption $feature)
$provider = current($providers); //Asume primer IDP que encuentra!
$options = $provider->getOptions();

$endpoint = $provider->getEndpoint();
echo "Procesando proveedor '{$provider->getName()}': ";

if ($endpoint == '') return; //Nada para configurar
$endpoint = $provider->getEndpoint();
if ($endpoint == '') {
echo "no posee configurado 'endpoint'\n";
return;
}
$iniInstalacion = new \toba_ini($this->instalacion->archivo_info_basica());

$iniInstalacion->agregar_entrada("autenticacion", "saml_onelogin");
Expand Down Expand Up @@ -272,6 +288,8 @@ protected function postConsumeSamlIdp(Consumption $feature)
}
$iniSaml->agregar_entrada("idp:".$endpoint, $idp);
$iniSaml->guardar();

echo "configurado con '{$provider->getEndpoint()}'\n";
}

//---------------------------------------------------------------
Expand Down Expand Up @@ -302,7 +320,7 @@ protected function preProvideApi(Provision $feature)
$options['auth']['type'] = $iniServer->get_datos_entrada("autenticacion");
}

$publicKey = $this->getAraiSyncKeyPublic();
$publicKey = $this->getAraiSyncKeyPublic();
$options['auth']['credentials']['cert'] = $publicKey;

$endpoint = $this->getProyectoUrl();
Expand Down Expand Up @@ -347,6 +365,9 @@ protected function postProvideApi(Provision $feature)
$iniServidorUsuarios = \toba_modelo_rest::get_ini_usuarios($modeloProyecto);
$iniServidorUsuarios->vaciar();

$cant = count($feature->getConsumers());
echo "Detectando clientes de api '{$feature->getName()}': {$cant}\n";

foreach ($feature->getConsumers() as $consumer) {
$authInfo = $consumer->getAuth();
if (empty($authInfo)) continue;
Expand Down Expand Up @@ -374,6 +395,9 @@ protected function getProyectoUrl()
$archivo = $this->instalacion->get_instancia($this->getInstanciaId())->get_dir()."/instancia.ini";
throw new \Exception("Es necesario especificar la URL completa del sistema en el atributo 'full_url' de la seccion [$proyecto] del archivo $archivo");
}
if (substr($fullUrl, -1) == '/') {
$fullUrl = substr($fullUrl, 0, -1);
}
return $fullUrl;
}

Expand Down Expand Up @@ -509,7 +533,7 @@ protected function getIniClienteRest($apiId, $acceso)

$dirIni = \toba_modelo_rest::get_dir_consumidor($modeloProyecto->get_dir_instalacion_proyecto(), $apiId);
if (! \toba_modelo_rest::existe_ini_cliente($modeloProyecto, $apiId)) {
throw new \Exception("No se puden enviar las credenciales de la api porque no están definidas en el archivo '$dirIni'");
return;
}

return \toba_modelo_rest::get_ini_cliente($modeloProyecto, $apiId);
Expand All @@ -532,7 +556,8 @@ protected function getCredencialesClienteSSL($auth)
{
$sslUtils = new SSLCertUtils();
if (!isset($auth['credentials']['cert'])) {
throw new \Exception("Se intenta configurar auth de tipo ssl pero no se provee certificado\n");
echo "Se intenta configurar auth de tipo ssl pero no se provee certificado\n";
return null;
}

$sslUtils->loadCert($auth['credentials']['cert']);
Expand All @@ -550,8 +575,9 @@ protected function getCredencialesClienteSSL($auth)

protected function getCredencialesClienteSimple($auth)
{
echo "Procesando cliente con usuario '{$auth['credentials']['user']}':";
if (!isset($auth['credentials']['cert'])) {
throw new \Exception("Se intenta configurar el cliente '{$auth['credentials']['user']}' pero no provee el certificado\n");
return;
}

$privateKey = $this->getAraiSyncKeyPrivate();
Expand All @@ -561,9 +587,19 @@ protected function getCredencialesClienteSimple($auth)

$encryptedAuth = AbstractAuth::getInstance($auth['type'], $auth['credentials'], true, $privateKey, $certPublic);

// se desencripta la clave del cliente con el certificado privado del server y el publico del cliente
$decryptedCredentials = $encryptedAuth->getDecryptedCredentials();
$decryptedCredentials = false;
try{
// se desencripta la clave del cliente con el certificado privado del server y el publico del cliente
$decryptedCredentials = $encryptedAuth->getDecryptedCredentials();
} catch (\Exception $e) {
echo " {$e->getMessage()}\n";
}

if (!$decryptedCredentials){
return;
}

echo " Desencriptado correcto de la clave\n";
$credentials = [
'user' => $auth['credentials']['user'],
'data' => array('password' => $decryptedCredentials['password'])
Expand All @@ -574,7 +610,13 @@ protected function getCredencialesClienteSimple($auth)

protected function actualizarClienteIni($provider, $acceso)
{
$iniCliente = $this->getIniClienteRest($acceso['rest-id'], $acceso);
$apiId = $acceso['rest-id'];
$iniCliente = $this->getIniClienteRest($apiId, $acceso);

if (!$iniCliente){
echo "el cliente de la api '$apiId' no esta correctamente configurado\n";
return;
}

$datos = $iniCliente->get_datos_entrada('conexion');

Expand All @@ -584,17 +626,24 @@ protected function actualizarClienteIni($provider, $acceso)

$iniCliente->agregar_entrada("conexion", $datos);
$iniCliente->guardar();

echo "configurado con '{$provider->getEndpoint()}'\n";
}

protected function configurarCliente($feature, $opciones)
{
$iniCliente = $this->getIniClienteRest($opciones['rest-id'], $opciones);
if (!$iniCliente){
return;
}

$provider = current($feature->getProviders());
if (!empty($provider)){
$authServer = $provider->getOptions()['auth'];
if (empty($provider)){
return;
}

$authServer = $provider->getOptions()['auth'];

$authCliente = $iniCliente->get_datos_entrada('conexion');

if ($authCliente['auth_tipo'] == 'ssl'){
Expand All @@ -611,12 +660,14 @@ protected function configurarCliente($feature, $opciones)
protected function configurarClienteSSL($feature, $authServer, $authCliente)
{
if (!isset($authCliente['cert_file'])) {
throw new \Exception("Se intenta enviar los datos de conexion para {$feature->getName()} pero no se seteó la propiedad 'cert_file'");
echo "Se intenta enviar los datos de conexion a la api '{$feature->getName()}' pero no se seteó la propiedad 'cert_file'\n";
return null;
}

$pathCert = $authCliente['cert_file'];
if (!file_exists($pathCert)) {
throw new \Exception("El certificado para {$feature->getName()} no se encuentra en el path '$pathCert'");
echo "El certificado para {$feature->getName()} no se encuentra en el path '$pathCert'\n";
return null;
}

$credentials = [
Expand All @@ -629,7 +680,8 @@ protected function configurarClienteSSL($feature, $authServer, $authCliente)
protected function configurarClienteSimple($feature, $authServer, $authCliente)
{
if (empty($authServer['credentials']['cert'])){
throw new \Exception("Se intenta enviar los datos de conexion para '{$feature->getName()}' pero no se seteó el certificado del servidor");
echo "Se intenta enviar los datos de conexion a la api '{$feature->getName()}' pero no se seteó la propiedad 'cert' del servidor\n";
return null;
}

$credentials = [
Expand Down

0 comments on commit c421857

Please sign in to comment.