Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-18751

REST api controller does not identify siteaccess correctly in non vhost mode

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Medium Medium
    • Resolution: Unresolved
    • Affects Version/s: 2011.9, 4.6.0-dev
    • Fix Version/s: None
    • Labels:
      None

      Description

      The problem seems to come from a simple oneliner: in index_rest.php, line 20:

      eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) == 'true' );

      should be

      eZSys::init( 'index_rest.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) == 'true' );

      After doing this change, accessing an url like the following:

      http://localhost/ezp/installs/ezpublish-4.5.0-ent/index_rest.php/admin_site/api/ezp
      /1/content/nodes/2

      seems to be working with the admin_site siteaccess activated (eg. the cookie name used for the session changes)

        Activity

        Hide
        Gaetano Giunta added a comment -

        Actually to make it work, also the method has to be changed in mvc_configuration.php:

            public function createRequestParser()
            {
                $parser = new ezpRestHttpRequestParser();
                if ( strpos( $_SERVER['SCRIPT_NAME'], self::INDEX_FILE ) !== false ) // Non-vhost mode
                {
                    // In non-vhost mode we need to build the prefix to be removed from URI
                    // This prefix is contained in SCRIPT_NAME server variable
                    $parser->prefix = $_SERVER['SCRIPT_NAME'];
                    if ( strpos( $_SERVER['REQUEST_URI'], self::INDEX_FILE ) === false ) // Index file doesn't appear in requested URI, remove it from the prefix
                    {
                        $parser->prefix = str_replace( '/'.self::INDEX_FILE, '', $parser->prefix );
         
                    }
                    
                    // gg 2011.10.11: make non-vhost mode work: allow siteaccess as first part of uri
                    /*var_dump($_SERVER['SCRIPT_NAME']);
                    var_dump($_SERVER['REQUEST_URI']);
                    var_dump($parser->prefix);*/
                    $sa = eZSiteaccess::current();
                    if ( strpos( $_SERVER['REQUEST_URI'], $parser->prefix . '/' . $sa['name'] ) === 0 )
                    {
                        $parser->prefix = $parser->prefix . '/' . $sa['name'];
                    }
                }
         
                return $parser;
            }
        

        Show
        Gaetano Giunta added a comment - Actually to make it work, also the method has to be changed in mvc_configuration.php: public function createRequestParser() { $parser = new ezpRestHttpRequestParser(); if ( strpos( $_SERVER['SCRIPT_NAME'], self::INDEX_FILE ) !== false ) // Non-vhost mode { // In non-vhost mode we need to build the prefix to be removed from URI // This prefix is contained in SCRIPT_NAME server variable $parser->prefix = $_SERVER['SCRIPT_NAME']; if ( strpos( $_SERVER['REQUEST_URI'], self::INDEX_FILE ) === false ) // Index file doesn't appear in requested URI, remove it from the prefix { $parser->prefix = str_replace( '/'.self::INDEX_FILE, '', $parser->prefix );   } // gg 2011.10.11: make non-vhost mode work: allow siteaccess as first part of uri /*var_dump($_SERVER['SCRIPT_NAME']); var_dump($_SERVER['REQUEST_URI']); var_dump($parser->prefix);*/ $sa = eZSiteaccess::current(); if ( strpos( $_SERVER['REQUEST_URI'], $parser->prefix . '/' . $sa['name'] ) === 0 ) { $parser->prefix = $parser->prefix . '/' . $sa['name']; } }   return $parser; }

          People

          • Assignee:
            unknown
            Reporter:
            Gaetano Giunta
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: