Browse Source

Se sobreescribio el handle del AppKernel para cargar los trusted proxies.

Se quito la rama FD3-284 del base-admin-bundle
gabriel 7 years ago
parent
commit
c457cfdac4
3 changed files with 36 additions and 15 deletions
  1. 27 6
      app/AppKernel.php
  2. 1 1
      composer.json
  3. 8 8
      composer.lock

+ 27 - 6
app/AppKernel.php

@@ -2,6 +2,8 @@
 
 use Symfony\Component\HttpKernel\Kernel;
 use Symfony\Component\Config\Loader\LoaderInterface;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\HttpFoundation\Request;
 
 class AppKernel extends Kernel
 {
@@ -15,7 +17,7 @@ class AppKernel extends Kernel
             new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
             new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
             new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
-            
+
             new Sonata\CoreBundle\SonataCoreBundle(),
             new Sonata\BlockBundle\SonataBlockBundle(),
             new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
@@ -30,14 +32,14 @@ class AppKernel extends Kernel
 
             new MigrationsBundle\MigrationsBundle(),
             new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
-            
+
             new WebserviceBundle\WebserviceBundle(),
             new Base\AdminBundle\BaseAdminBundle(),
             new Base\OAuthClientBundle\BaseOAuthClientBundle(),
             new DeviceBundle\DeviceBundle(),
             new ExtraDataBundle\ExtraDataBundle(),
             new OwnerVoterBundle\OwnerVoterBundle(),
-            
+
             new StatsBundle\StatsBundle(),
             new RedisBundle\RedisBundle(),
             new BaseStatsBundle\BaseStatsBundle(),
@@ -73,16 +75,35 @@ class AppKernel extends Kernel
 
     public function getCacheDir()
     {
-        return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
+        return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
     }
 
     public function getLogDir()
     {
-        return dirname(__DIR__).'/var/logs';
+        return dirname(__DIR__) . '/var/logs';
     }
 
     public function registerContainerConfiguration(LoaderInterface $loader)
     {
-        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
+        $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
+    {
+        if (false === $this->booted) {
+            $this->boot();
+        }
+        // se puede sacar la variable nginx-proxy porque es el nombre del docker y puede variar
+        // con REMOTRA_ADDR obtengo el mismo valor (http://symfony.com/doc/current/deployment/proxies.html)
+        //gethostbyname("nginx-proxy") == $request->server->get('REMOTE_ADDR')
+        if ($this->container->hasParameter("nginx_name")) {
+            Request::setTrustedProxies(
+                array('127.0.0.1', $this->container->getParameter("nginx_name")),
+                Request::HEADER_X_FORWARDED_FOR);
+        }
+        return parent::handle($request, $type, $catch);
     }
 }

+ 1 - 1
composer.json

@@ -165,7 +165,7 @@
         "jdorn/sql-formatter": "~1.2.17",
         "ik/audit-bundle": "dev-master",
         "ik/auth-bundle": "dev-FD3-284",
-        "ik/base-admin-bundle": "dev-FD3-284",
+        "ik/base-admin-bundle": "dev-master",
         "ik/device-bundle": "dev-master",
         "ik/extra-data-bundle": "dev-master",
         "ik/leaflet-bundle": "dev-master",

+ 8 - 8
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "68c0631b579c7af0b1be1b28dd78ffcf",
+    "content-hash": "2de752e14d81adead15fa9acb144c154",
     "packages": [
         {
             "name": "behat/transliterator",
@@ -1413,11 +1413,11 @@
         },
         {
             "name": "ik/base-admin-bundle",
-            "version": "dev-FD3-284",
+            "version": "dev-master",
             "source": {
                 "type": "git",
                 "url": "ssh://git@infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseAdmin.git",
-                "reference": "eb512db3d1778c9a4687d51b3519b492529bb5fe"
+                "reference": "53d81ce96e6b94af88c2546c5470fc3ad050a7bc"
             },
             "type": "library",
             "autoload": {
@@ -1432,7 +1432,7 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2017-11-03T13:54:39+00:00"
+            "time": "2017-10-27T15:27:11+00:00"
         },
         {
             "name": "ik/device-bundle",
@@ -1604,7 +1604,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseStatsBundle.git",
-                "reference": "dab55249f7a50ede61a6c490b87426d7d5890747"
+                "reference": "9572b7d0d297e3394710e3a05027f51ab1f62525"
             },
             "type": "library",
             "autoload": {
@@ -1617,7 +1617,7 @@
                 "BaseStatsBundle",
                 "Flowdat 3"
             ],
-            "time": "2017-11-02T15:39:39+00:00"
+            "time": "2017-11-03T16:46:15+00:00"
         },
         {
             "name": "ik/stats/fiberhome-bundle",
@@ -1751,7 +1751,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
-                "reference": "2094aebf7b1d5b0ea09f68a6d5fe9c29a57393bf"
+                "reference": "2adbaaabc41470ae0df29bfeae00c98ea65e7e71"
             },
             "require": {
                 "php-amqplib/rabbitmq-bundle": "^1.12"
@@ -1781,7 +1781,7 @@
                 "bundle",
                 "workflow"
             ],
-            "time": "2017-11-03T13:23:43+00:00"
+            "time": "2017-11-03T16:52:11+00:00"
         },
         {
             "name": "incenteev/composer-parameter-handler",