← Back to team overview

openerp-india team mailing list archive

[Bug 1065127] [NEW] dbfilter doesn't work in proxy configurations

 

Public bug reported:

First reported in https://bugs.launchpad.net/openobject-
server/+bug/940439/comments/6 by Alvar V. (alvar-vilu), but it's
actually a different bug than the one discussed there:

When OpenERP (at least 6.1+) is deployed behind a proxy, the dbfilter
option won't work.

This is due to openerp/addons/web/controllers/main.py (lines 136+)
doing:

def db_list(req):
    dbs = []
    proxy = req.session.proxy("db")
    dbs = proxy.list()
    h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
    d = h.split('.')[0]
    r = req.config.dbfilter.replace('%h', h).replace('%d', d)
    dbs = [i for i in dbs if re.match(r, i)]
    return dbs

However, in proxy configs, it should user HTTP_X_FORWARDED_HOST as
filter.

This can easily be done by checking whether that var is in the environ:

def db_list(req):
    dbs = []
    proxy = req.session.proxy("db")
    dbs = proxy.list()
    if 'HTTP_X_FORWARDED_HOST' in req.httprequest.environ:
        h = 'HTTP_X_FORWARDED_HOST'
    else:
        h = 'HTTP_HOST'
    h = req.httprequest.environ[h].split(':')[0]
    d = h.split('.')[0]
    r = req.config.dbfilter.replace('%h', h).replace('%d', d)
    dbs = [i for i in dbs if re.match(r, i)]
    return dbs

** Affects: openobject-server
     Importance: Undecided
         Status: Confirmed


** Tags: dbfilter proxy

** Changed in: openobject-server
       Status: New => Confirmed

** Description changed:

  When OpenERP (at least 6.1+) is deployed behind a proxy, the dbfilter
  option won't work.
  
  This is due to openerp/addons/web/controllers/main.py (lines 136+)
  doing:
  
  def db_list(req):
-     dbs = []
-     proxy = req.session.proxy("db")
-     dbs = proxy.list()
-     h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
-     d = h.split('.')[0]
-     r = req.config.dbfilter.replace('%h', h).replace('%d', d)
-     dbs = [i for i in dbs if re.match(r, i)]
-     return dbs
+     dbs = []
+     proxy = req.session.proxy("db")
+     dbs = proxy.list()
+     h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
+     d = h.split('.')[0]
+     r = req.config.dbfilter.replace('%h', h).replace('%d', d)
+     dbs = [i for i in dbs if re.match(r, i)]
+     return dbs
  
  However, in proxy configs, it should user HTTP_X_FORWARDED_HOST as
  filter.
  
  This can easily be done by checking whether that var is in the environ:
  
  def db_list(req):
-     dbs = []
-     proxy = req.session.proxy("db")
-     dbs = proxy.list()
-     if 'HTTP_X_FORWARDED_HOST' in req.httprequest.environ:
-         h = 'HTTP_X_FORWARDED_HOST'
-     else:
-         h = 'HTTP_HOST'
-     h = req.httprequest.environ[h].split(':')[0]
-     d = h.split('.')[0]
-     r = req.config.dbfilter.replace('%h', h).replace('%d', d)
-     dbs = [i for i in dbs if re.match(r, i)]
-     return dbs
+     dbs = []
+     proxy = req.session.proxy("db")
+     dbs = proxy.list()
+     if 'HTTP_X_FORWARDED_HOST' in req.httprequest.environ:
+         h = 'HTTP_X_FORWARDED_HOST'
+     else:
+         h = 'HTTP_HOST'
+     h = req.httprequest.environ[h].split(':')[0]
+     d = h.split('.')[0]
+     r = req.config.dbfilter.replace('%h', h).replace('%d', d)
+     dbs = [i for i in dbs if re.match(r, i)]
+     return dbs

** Description changed:

+ First reported in #940439 by Alvar V. (alvar-vilu), but it's actually a
+ different bug than the one discussed there:
+ 
  When OpenERP (at least 6.1+) is deployed behind a proxy, the dbfilter
  option won't work.
  
  This is due to openerp/addons/web/controllers/main.py (lines 136+)
  doing:
  
  def db_list(req):
      dbs = []
      proxy = req.session.proxy("db")
      dbs = proxy.list()
      h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
      d = h.split('.')[0]
      r = req.config.dbfilter.replace('%h', h).replace('%d', d)
      dbs = [i for i in dbs if re.match(r, i)]
      return dbs
  
  However, in proxy configs, it should user HTTP_X_FORWARDED_HOST as
  filter.
  
  This can easily be done by checking whether that var is in the environ:
  
  def db_list(req):
      dbs = []
      proxy = req.session.proxy("db")
      dbs = proxy.list()
      if 'HTTP_X_FORWARDED_HOST' in req.httprequest.environ:
          h = 'HTTP_X_FORWARDED_HOST'
      else:
          h = 'HTTP_HOST'
      h = req.httprequest.environ[h].split(':')[0]
      d = h.split('.')[0]
      r = req.config.dbfilter.replace('%h', h).replace('%d', d)
      dbs = [i for i in dbs if re.match(r, i)]
      return dbs

** Tags added: proxy

** Description changed:

- First reported in #940439 by Alvar V. (alvar-vilu), but it's actually a
- different bug than the one discussed there:
+ First reported in https://bugs.launchpad.net/openobject-
+ server/+bug/940439/comments/6 by Alvar V. (alvar-vilu), but it's
+ actually a different bug than the one discussed there:
  
  When OpenERP (at least 6.1+) is deployed behind a proxy, the dbfilter
  option won't work.
  
  This is due to openerp/addons/web/controllers/main.py (lines 136+)
  doing:
  
  def db_list(req):
      dbs = []
      proxy = req.session.proxy("db")
      dbs = proxy.list()
      h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
      d = h.split('.')[0]
      r = req.config.dbfilter.replace('%h', h).replace('%d', d)
      dbs = [i for i in dbs if re.match(r, i)]
      return dbs
  
  However, in proxy configs, it should user HTTP_X_FORWARDED_HOST as
  filter.
  
  This can easily be done by checking whether that var is in the environ:
  
  def db_list(req):
      dbs = []
      proxy = req.session.proxy("db")
      dbs = proxy.list()
      if 'HTTP_X_FORWARDED_HOST' in req.httprequest.environ:
          h = 'HTTP_X_FORWARDED_HOST'
      else:
          h = 'HTTP_HOST'
      h = req.httprequest.environ[h].split(':')[0]
      d = h.split('.')[0]
      r = req.config.dbfilter.replace('%h', h).replace('%d', d)
      dbs = [i for i in dbs if re.match(r, i)]
      return dbs

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/1065127

Title:
  dbfilter doesn't work in proxy configurations

Status in OpenERP Server:
  Confirmed

Bug description:
  First reported in https://bugs.launchpad.net/openobject-
  server/+bug/940439/comments/6 by Alvar V. (alvar-vilu), but it's
  actually a different bug than the one discussed there:

  When OpenERP (at least 6.1+) is deployed behind a proxy, the dbfilter
  option won't work.

  This is due to openerp/addons/web/controllers/main.py (lines 136+)
  doing:

  def db_list(req):
      dbs = []
      proxy = req.session.proxy("db")
      dbs = proxy.list()
      h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
      d = h.split('.')[0]
      r = req.config.dbfilter.replace('%h', h).replace('%d', d)
      dbs = [i for i in dbs if re.match(r, i)]
      return dbs

  However, in proxy configs, it should user HTTP_X_FORWARDED_HOST as
  filter.

  This can easily be done by checking whether that var is in the
  environ:

  def db_list(req):
      dbs = []
      proxy = req.session.proxy("db")
      dbs = proxy.list()
      if 'HTTP_X_FORWARDED_HOST' in req.httprequest.environ:
          h = 'HTTP_X_FORWARDED_HOST'
      else:
          h = 'HTTP_HOST'
      h = req.httprequest.environ[h].split(':')[0]
      d = h.split('.')[0]
      r = req.config.dbfilter.replace('%h', h).replace('%d', d)
      dbs = [i for i in dbs if re.match(r, i)]
      return dbs

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1065127/+subscriptions


Follow ups

References