diff --git a/base_remote/README.rst b/base_remote/README.rst new file mode 100644 index 000000000..5e76f9f11 --- /dev/null +++ b/base_remote/README.rst @@ -0,0 +1,81 @@ +=========== +Remote Base +=========== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/14.0/base_remote + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_remote + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/149/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to store all the connected remotes (external ip addresses) to Odoo. +It should be used with other modules in order to check remote's configurations. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +When installed, all remotes will be stored by `hostname` on `res.remote`. +They can be viewed on `Settings / Remotes`. +The last IP of the remote will be stored. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Creu Blanca + +Contributors +~~~~~~~~~~~~ + +* Enric Tobella + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_remote/__init__.py b/base_remote/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/base_remote/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_remote/__manifest__.py b/base_remote/__manifest__.py new file mode 100644 index 000000000..0c0a02eb0 --- /dev/null +++ b/base_remote/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright (c) 2018 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Remote Base", + "version": "15.0.1.0.0", + "category": "Generic Modules/Base", + "author": "Creu Blanca, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-tools", + "license": "AGPL-3", + "depends": ["web"], + "data": ["security/ir.model.access.csv", "views/res_remote_views.xml"], + "installable": True, +} diff --git a/base_remote/i18n/base_remote.pot b/base_remote/i18n/base_remote.pot new file mode 100644 index 000000000..1321a06f1 --- /dev/null +++ b/base_remote/i18n/base_remote.pot @@ -0,0 +1,136 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_remote +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \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" + +#. module: base_remote +#: model:ir.model,name:base_remote.model_base +msgid "Base" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__changeset_change_ids +#: model:ir.model.fields,field_description:base_remote.field_res_users__changeset_change_ids +msgid "Changeset Changes" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__changeset_ids +#: model:ir.model.fields,field_description:base_remote.field_res_users__changeset_ids +msgid "Changesets" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__count_pending_changeset_changes +#: model:ir.model.fields,field_description:base_remote.field_res_users__count_pending_changeset_changes +msgid "Count Pending Changeset Changes" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__count_pending_changesets +#: model:ir.model.fields,field_description:base_remote.field_res_users__count_pending_changesets +msgid "Count Pending Changesets" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__create_uid +msgid "Created by" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__create_date +msgid "Created on" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__display_name +#: model:ir.model.fields,field_description:base_remote.field_res_users__display_name +msgid "Display Name" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__name +msgid "Hostname" +msgstr "" + +#. module: base_remote +#: model:ir.model.constraint,message:base_remote.constraint_res_remote_name_unique +msgid "Hostname must be unique" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__id +#: model:ir.model.fields,field_description:base_remote.field_res_users__id +msgid "ID" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__in_network +msgid "In Network" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__ip +msgid "Ip" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote____last_update +#: model:ir.model.fields,field_description:base_remote.field_res_users____last_update +msgid "Last Modified on" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__write_date +msgid "Last Updated on" +msgstr "" + +#. module: base_remote +#: model_terms:ir.ui.view,arch_db:base_remote.res_remote_form +msgid "Remote" +msgstr "" + +#. module: base_remote +#: model:ir.actions.act_window,name:base_remote.res_remote_action +#: model:ir.model,name:base_remote.model_res_remote +#: model:ir.ui.menu,name:base_remote.res_remote_menu +#: model_terms:ir.ui.view,arch_db:base_remote.res_remote_tree +msgid "Remotes" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,help:base_remote.field_res_remote__in_network +msgid "Shows if the remote can be found through the socket" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__smart_search +#: model:ir.model.fields,field_description:base_remote.field_res_users__smart_search +msgid "Smart Search" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__user_can_see_changeset +#: model:ir.model.fields,field_description:base_remote.field_res_users__user_can_see_changeset +msgid "User Can See Changeset" +msgstr "" + +#. module: base_remote +#: model:ir.model,name:base_remote.model_res_users +msgid "Users" +msgstr "" diff --git a/base_remote/i18n/es.po b/base_remote/i18n/es.po new file mode 100644 index 000000000..34dd9802d --- /dev/null +++ b/base_remote/i18n/es.po @@ -0,0 +1,142 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_remote +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2018-07-13 08:36+0000\n" +"Last-Translator: Enric Tobella \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.0.1\n" + +#. module: base_remote +#: model:ir.model,name:base_remote.model_base +msgid "Base" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__changeset_change_ids +#: model:ir.model.fields,field_description:base_remote.field_res_users__changeset_change_ids +msgid "Changeset Changes" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__changeset_ids +#: model:ir.model.fields,field_description:base_remote.field_res_users__changeset_ids +msgid "Changesets" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__count_pending_changeset_changes +#: model:ir.model.fields,field_description:base_remote.field_res_users__count_pending_changeset_changes +msgid "Count Pending Changeset Changes" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__count_pending_changesets +#: model:ir.model.fields,field_description:base_remote.field_res_users__count_pending_changesets +msgid "Count Pending Changesets" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__create_date +msgid "Created on" +msgstr "Creado el" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__display_name +#: model:ir.model.fields,field_description:base_remote.field_res_users__display_name +msgid "Display Name" +msgstr "Nombre a mostrar" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__name +msgid "Hostname" +msgstr "Nombre del host" + +#. module: base_remote +#: model:ir.model.constraint,message:base_remote.constraint_res_remote_name_unique +msgid "Hostname must be unique" +msgstr "El nombre del host debe ser único" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__id +#: model:ir.model.fields,field_description:base_remote.field_res_users__id +msgid "ID" +msgstr "ID" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__in_network +msgid "In Network" +msgstr "En la Red local" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__ip +msgid "Ip" +msgstr "IP" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote____last_update +#: model:ir.model.fields,field_description:base_remote.field_res_users____last_update +msgid "Last Modified on" +msgstr "Última actualización por" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__write_uid +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__write_date +msgid "Last Updated on" +msgstr "Última actualización el" + +#. module: base_remote +#: model_terms:ir.ui.view,arch_db:base_remote.res_remote_form +msgid "Remote" +msgstr "Remoto" + +#. module: base_remote +#: model:ir.actions.act_window,name:base_remote.res_remote_action +#: model:ir.model,name:base_remote.model_res_remote +#: model:ir.ui.menu,name:base_remote.res_remote_menu +#: model_terms:ir.ui.view,arch_db:base_remote.res_remote_tree +msgid "Remotes" +msgstr "Remotos" + +#. module: base_remote +#: model:ir.model.fields,help:base_remote.field_res_remote__in_network +msgid "Shows if the remote can be found through the socket" +msgstr "Muestra si el remoto se pudo encontrar a través del socket" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__smart_search +#: model:ir.model.fields,field_description:base_remote.field_res_users__smart_search +msgid "Smart Search" +msgstr "" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__user_can_see_changeset +#: model:ir.model.fields,field_description:base_remote.field_res_users__user_can_see_changeset +msgid "User Can See Changeset" +msgstr "" + +#. module: base_remote +#: model:ir.model,name:base_remote.model_res_users +msgid "Users" +msgstr "Usuarios" + +#~ msgid "base" +#~ msgstr "base" diff --git a/base_remote/i18n/es_AR.po b/base_remote/i18n/es_AR.po new file mode 100644 index 000000000..1756a376a --- /dev/null +++ b/base_remote/i18n/es_AR.po @@ -0,0 +1,139 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_remote +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-03-28 01:17+0000\n" +"Last-Translator: Ignacio Buioli \n" +"Language-Team: none\n" +"Language: es_AR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: base_remote +#: model:ir.model,name:base_remote.model_base +msgid "Base" +msgstr "Base" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__changeset_change_ids +#: model:ir.model.fields,field_description:base_remote.field_res_users__changeset_change_ids +msgid "Changeset Changes" +msgstr "Cambios en el Conjunto de Cambios" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__changeset_ids +#: model:ir.model.fields,field_description:base_remote.field_res_users__changeset_ids +msgid "Changesets" +msgstr "Conjunto de Cambios" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__count_pending_changeset_changes +#: model:ir.model.fields,field_description:base_remote.field_res_users__count_pending_changeset_changes +msgid "Count Pending Changeset Changes" +msgstr "Contar los Cambios Pendientes del Conjunto de Cambios" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__count_pending_changesets +#: model:ir.model.fields,field_description:base_remote.field_res_users__count_pending_changesets +msgid "Count Pending Changesets" +msgstr "Contar Conjunto de Cambios Pendientes" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__create_uid +msgid "Created by" +msgstr "Creado por" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__create_date +msgid "Created on" +msgstr "Creado en" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__display_name +#: model:ir.model.fields,field_description:base_remote.field_res_users__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__name +msgid "Hostname" +msgstr "Nombre del Host" + +#. module: base_remote +#: model:ir.model.constraint,message:base_remote.constraint_res_remote_name_unique +msgid "Hostname must be unique" +msgstr "El nombre del host debe ser único" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__id +#: model:ir.model.fields,field_description:base_remote.field_res_users__id +msgid "ID" +msgstr "ID" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__in_network +msgid "In Network" +msgstr "En Red" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__ip +msgid "Ip" +msgstr "IP" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote____last_update +#: model:ir.model.fields,field_description:base_remote.field_res_users____last_update +msgid "Last Modified on" +msgstr "Última modificación en" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__write_uid +msgid "Last Updated by" +msgstr "Última actualización realizada por" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__write_date +msgid "Last Updated on" +msgstr "Última actualización el" + +#. module: base_remote +#: model_terms:ir.ui.view,arch_db:base_remote.res_remote_form +msgid "Remote" +msgstr "Remoto" + +#. module: base_remote +#: model:ir.actions.act_window,name:base_remote.res_remote_action +#: model:ir.model,name:base_remote.model_res_remote +#: model:ir.ui.menu,name:base_remote.res_remote_menu +#: model_terms:ir.ui.view,arch_db:base_remote.res_remote_tree +msgid "Remotes" +msgstr "Remotos" + +#. module: base_remote +#: model:ir.model.fields,help:base_remote.field_res_remote__in_network +msgid "Shows if the remote can be found through the socket" +msgstr "Muestro si el remoto se puede encontrar a través del socket" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__smart_search +#: model:ir.model.fields,field_description:base_remote.field_res_users__smart_search +msgid "Smart Search" +msgstr "Búsqueda Inteligente" + +#. module: base_remote +#: model:ir.model.fields,field_description:base_remote.field_res_remote__user_can_see_changeset +#: model:ir.model.fields,field_description:base_remote.field_res_users__user_can_see_changeset +msgid "User Can See Changeset" +msgstr "El usuario puede ver el Conjunto de Cambios" + +#. module: base_remote +#: model:ir.model,name:base_remote.model_res_users +msgid "Users" +msgstr "Usuarios" diff --git a/base_remote/models/__init__.py b/base_remote/models/__init__.py new file mode 100644 index 000000000..afa66d0dc --- /dev/null +++ b/base_remote/models/__init__.py @@ -0,0 +1,3 @@ +from . import base +from . import res_remote +from . import res_users diff --git a/base_remote/models/base.py b/base_remote/models/base.py new file mode 100644 index 000000000..cb128d5c0 --- /dev/null +++ b/base_remote/models/base.py @@ -0,0 +1,18 @@ +# Copyright 2018 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from threading import current_thread + +from odoo import models + + +class Base(models.AbstractModel): + _inherit = "base" + + @property + def remote(self): + try: + remote_addr = current_thread().environ["REMOTE_ADDR"] + except (KeyError, AttributeError): + return self.env["res.remote"] + return self.env["res.remote"]._get_remote(remote_addr) diff --git a/base_remote/models/res_remote.py b/base_remote/models/res_remote.py new file mode 100644 index 000000000..8e57d9bc1 --- /dev/null +++ b/base_remote/models/res_remote.py @@ -0,0 +1,42 @@ +# Copyright 2018 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import logging +import socket + +from odoo import api, fields, models + + +class ResRemote(models.Model): + _name = "res.remote" + _description = "Remotes" + + name = fields.Char(required=True, string="Hostname", index=True, readonly=True) + ip = fields.Char(required=True) + in_network = fields.Boolean( + required=True, help="Shows if the remote can be found through the socket" + ) + + _sql_constraints = [("name_unique", "unique(name)", "Hostname must be unique")] + + @api.model + def _create_vals(self, addr, hostname): + return { + "name": hostname or addr, + "ip": addr, + "in_network": bool(hostname), + } + + @api.model + def _get_remote(self, addr): + try: + hostname, alias, ips = socket.gethostbyaddr(addr) + except socket.herror: + logging.warning("Remote with ip %s could not be found" % addr) + hostname = False + remote = self.search([("name", "=ilike", hostname or addr)]) + if not remote: + remote = self.create(self._create_vals(addr, hostname)) + if remote.ip != addr: + # IPs can change through time, but hostname should not change + remote.write({"ip": addr}) + return remote diff --git a/base_remote/models/res_users.py b/base_remote/models/res_users.py new file mode 100644 index 000000000..8bb0d3928 --- /dev/null +++ b/base_remote/models/res_users.py @@ -0,0 +1,55 @@ +# Copyright 2018 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from threading import current_thread + +from odoo import SUPERUSER_ID, api, models +from odoo.exceptions import AccessDenied +from odoo.service import wsgi_server +from odoo.tools import config + + +class ResUsers(models.Model): + _inherit = "res.users" + + def _register_hook(self): + """🐒-patch XML-RPC controller to know remote address.""" + super()._register_hook() + original_fn = wsgi_server.application_unproxied + + def _patch(environ, start_response): + current_thread().environ = environ + return original_fn(environ, start_response) + + wsgi_server.application_unproxied = _patch + + @classmethod + def _auth_check_remote(cls, login, method): + """Force a method to raise an AccessDenied on falsey return.""" + with cls.pool.cursor() as cr: + env = api.Environment(cr, SUPERUSER_ID, {}) + remote = env["res.users"].remote + if not config["test_enable"]: + remote.ensure_one() + result = method() + if not result: + # Force exception to record auth failure + raise AccessDenied() + return result + + # Override all auth-related core methods + @classmethod + def _login(cls, db, login, password, user_agent_env): + return cls._auth_check_remote( + login, + lambda: super(ResUsers, cls)._login(db, login, password, user_agent_env), + ) + + @classmethod + def authenticate(cls, db, login, password, user_agent_env): + return cls._auth_check_remote( + login, + lambda: super(ResUsers, cls).authenticate( + db, login, password, user_agent_env + ), + ) diff --git a/base_remote/readme/CONTRIBUTORS.rst b/base_remote/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..93ec993e0 --- /dev/null +++ b/base_remote/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Enric Tobella diff --git a/base_remote/readme/DESCRIPTION.rst b/base_remote/readme/DESCRIPTION.rst new file mode 100644 index 000000000..be5ce4d3f --- /dev/null +++ b/base_remote/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows to store all the connected remotes (external ip addresses) to Odoo. +It should be used with other modules in order to check remote's configurations. diff --git a/base_remote/readme/USAGE.rst b/base_remote/readme/USAGE.rst new file mode 100644 index 000000000..52ab7c552 --- /dev/null +++ b/base_remote/readme/USAGE.rst @@ -0,0 +1,3 @@ +When installed, all remotes will be stored by `hostname` on `res.remote`. +They can be viewed on `Settings / Remotes`. +The last IP of the remote will be stored. diff --git a/base_remote/security/ir.model.access.csv b/base_remote/security/ir.model.access.csv new file mode 100644 index 000000000..7642160aa --- /dev/null +++ b/base_remote/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_remote,access_remote,model_res_remote,base.group_user,1,0,0,0 +manage_remote,manage_remote,model_res_remote,base.group_system,1,1,0,0 diff --git a/base_remote/static/description/icon.png b/base_remote/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/base_remote/static/description/icon.png differ diff --git a/base_remote/static/description/index.html b/base_remote/static/description/index.html new file mode 100644 index 000000000..8a37c1601 --- /dev/null +++ b/base_remote/static/description/index.html @@ -0,0 +1,427 @@ + + + + + + +Remote Base + + + +
+

Remote Base

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

This module allows to store all the connected remotes (external ip addresses) to Odoo. +It should be used with other modules in order to check remote’s configurations.

+

Table of contents

+ +
+

Usage

+

When installed, all remotes will be stored by hostname on res.remote. +They can be viewed on Settings / Remotes. +The last IP of the remote will be stored.

+
+
+

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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Creu Blanca
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/server-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/base_remote/tests/__init__.py b/base_remote/tests/__init__.py new file mode 100644 index 000000000..2dbcf34b1 --- /dev/null +++ b/base_remote/tests/__init__.py @@ -0,0 +1 @@ +from . import test_remote diff --git a/base_remote/tests/test_remote.py b/base_remote/tests/test_remote.py new file mode 100644 index 000000000..d25cd5773 --- /dev/null +++ b/base_remote/tests/test_remote.py @@ -0,0 +1,59 @@ +# Copyright 2018 Creu Blanca +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from mock import patch + +from odoo import http +from odoo.tests import tagged +from odoo.tests.common import HttpCase + + +@tagged("post_install", "-at_install") +# Skip CSRF validation on tests +@patch(http.__name__ + ".WebRequest.validate_csrf", return_value=True) +class TestRemote(HttpCase): + def setUp(self): + super().setUp() + + # Complex password to avoid conflicts with `password_security` + self.good_password = "Admin$%02584" + self.data_demo = { + "login": "demo", + "password": "Demo%&/(908409**", + } + self.remote_addr = "127.0.0.1" + with self.cursor() as cr: + env = self.env(cr) + # Make sure involved users have good passwords + env.user.password = self.good_password + env["res.users"].search( + [("login", "=", self.data_demo["login"])] + ).password = self.data_demo["password"] + remote = self.env["res.remote"].search([("ip", "=", self.remote_addr)]) + if remote: + remote.unlink() + + def test_xmlrpc_login_ok(self, *args): + """Test Login""" + data1 = self.data_demo + self.assertTrue( + self.xmlrpc_common.authenticate( + self.env.cr.dbname, data1["login"], data1["password"], {} + ) + ) + with self.cursor() as cr: + env = self.env(cr) + self.assertTrue(env["res.remote"].search([("ip", "=", self.remote_addr)])) + + def test_xmlrpc_login_failure(self, *args): + """Test Login Failure""" + data1 = self.data_demo + data1["password"] = "Failure!" + self.assertFalse( + self.xmlrpc_common.authenticate( + self.env.cr.dbname, data1["login"], data1["password"], {} + ) + ) + with self.cursor() as cr: + env = self.env(cr) + self.assertTrue(env["res.remote"].search([("ip", "=", self.remote_addr)])) diff --git a/base_remote/views/res_remote_views.xml b/base_remote/views/res_remote_views.xml new file mode 100644 index 000000000..b100f9331 --- /dev/null +++ b/base_remote/views/res_remote_views.xml @@ -0,0 +1,48 @@ + + + + res.remote.form + res.remote + +
+ +
+

+ +

+
+ + + + + + + +
+
+
+
+ + res.remote.tree + res.remote + + + + + + + + + Remotes + ir.actions.act_window + res.remote + tree,form + + +
diff --git a/setup/base_remote/odoo/addons/base_remote b/setup/base_remote/odoo/addons/base_remote new file mode 120000 index 000000000..1dda6f4b9 --- /dev/null +++ b/setup/base_remote/odoo/addons/base_remote @@ -0,0 +1 @@ +../../../../base_remote \ No newline at end of file diff --git a/setup/base_remote/setup.py b/setup/base_remote/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/base_remote/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)