diff --git a/dbfilter_from_header/README.rst b/dbfilter_from_header/README.rst new file mode 100644 index 000000000..03293e46b --- /dev/null +++ b/dbfilter_from_header/README.rst @@ -0,0 +1,80 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +==================== +dbfilter_from_header +==================== + +This addon lets you pass a dbfilter as a HTTP header. + +This is interesting for setups where database names can't be mapped to proxied host names. + +Installation +============ + +To install this module, you only need to add it to your addons, and load it as +a server-wide module. + +This can be done with the ``load`` parameter in ``/etc/odoo.conf`` or with the +``--load`` command-line parameter + +``load = "web, dbfilter_from_header"`` + +Configuration +============= + +Please keep in mind that the standard odoo dbfilter configuration is still +applied before looking at the regular expression in the header. + +* For nginx, use: + + ``proxy_set_header X-Odoo-dbfilter [your filter regex];`` + +* For caddy, use: + + ``proxy_header X-Odoo-dbfilter [your filter regex]`` + +* For Apache, use: + + ``RequestHeader set X-Odoo-dbfilter [your filter regex]`` + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Stéphane Bidoul +* Yannick Vaucher +* Alexandre Fayolle +* Holger Brunn +* Laurent Mignon (aka lmi) +* Sandy Carter +* Fabio Vilchez +* Jos De Graeve +* Lai Tim Siu (Quaritle Limited) + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/dbfilter_from_header/__init__.py b/dbfilter_from_header/__init__.py new file mode 100644 index 000000000..b57de876a --- /dev/null +++ b/dbfilter_from_header/__init__.py @@ -0,0 +1,2 @@ + +from . import override diff --git a/dbfilter_from_header/__manifest__.py b/dbfilter_from_header/__manifest__.py new file mode 100644 index 000000000..82f462f65 --- /dev/null +++ b/dbfilter_from_header/__manifest__.py @@ -0,0 +1,28 @@ +# © 2013 Therp BV +# © 2014 ACSONE SA/NV +# Copyright 2018 Quartile Limited +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "dbfilter_from_header", + "summary": "Filter databases with HTTP headers", + "version": "11.0.1.0.0", + "author": "Therp BV,Odoo Community Association (OCA)", + "license": "AGPL-3", + "complexity": "normal", + "category": "Tools", + "depends": [ + 'web', + ], + "data": [ + ], + "js": [ + ], + "css": [ + ], + "auto_install": False, + 'installable': True, + "external_dependencies": { + 'python': [], + }, +} diff --git a/dbfilter_from_header/i18n/dbfilter_from_header.pot b/dbfilter_from_header/i18n/dbfilter_from_header.pot new file mode 100644 index 000000000..3c201b4a8 --- /dev/null +++ b/dbfilter_from_header/i18n/dbfilter_from_header.pot @@ -0,0 +1,16 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-03-14 17:40+0000\n" +"PO-Revision-Date: 2014-03-14 17:40+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + diff --git a/dbfilter_from_header/override.py b/dbfilter_from_header/override.py new file mode 100644 index 000000000..a347c30ed --- /dev/null +++ b/dbfilter_from_header/override.py @@ -0,0 +1,21 @@ +# © 2013 Therp BV +# © 2014 ACSONE SA/NV +# Copyright 2018 Quartile Limited +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import re +from odoo import http + +db_filter_org = http.db_filter + + +def db_filter(dbs, httprequest=None): + dbs = db_filter_org(dbs, httprequest) + httprequest = httprequest or http.request.httprequest + db_filter_hdr = httprequest.environ.get('HTTP_X_ODOO_DBFILTER') + if db_filter_hdr: + dbs = [db for db in dbs if re.match(db_filter_hdr, db)] + return dbs + + +http.db_filter = db_filter diff --git a/dbfilter_from_header/static/description/icon.png b/dbfilter_from_header/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/dbfilter_from_header/static/description/icon.png differ