You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
790 B

  1. # © 2013 Therp BV
  2. # © 2014 ACSONE SA/NV
  3. # Copyright 2018 Quartile Limited
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. import logging
  6. import re
  7. from odoo import http
  8. from odoo.tools import config
  9. db_filter_org = http.db_filter
  10. def db_filter(dbs, httprequest=None):
  11. dbs = db_filter_org(dbs, httprequest)
  12. httprequest = httprequest or http.request.httprequest
  13. db_filter_hdr = httprequest.environ.get('HTTP_X_ODOO_DBFILTER')
  14. if db_filter_hdr:
  15. dbs = [db for db in dbs if re.match(db_filter_hdr, db)]
  16. return dbs
  17. if config.get('proxy_mode') and \
  18. 'dbfilter_from_header' in config.get('server_wide_modules'):
  19. _logger = logging.getLogger(__name__)
  20. _logger.info('monkey patching http.db_filter')
  21. http.db_filter = db_filter