diff --git a/README.md b/README.md index b1ddf5a399..fcf8fed22f 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Available addons addon | version | maintainers | summary --- | --- | --- | --- [auth_api_key](auth_api_key/) | 18.0.1.0.0 | | Authenticate http requests from an API key +[auth_api_key_group](auth_api_key_group/) | 18.0.1.0.0 | [![simahawk](https://github.com/simahawk.png?size=30px)](https://github.com/simahawk) | Allow grouping API keys together. Grouping per se does nothing. This feature is supposed to be used by other modules to limit access to services or records based on groups of keys. +[auth_api_key_server_env](auth_api_key_server_env/) | 18.0.1.0.0 | | Configure api keys via server env. This can be very useful to avoid mixing your keys between your various environments when restoring databases. All you have to do is to add a new section to your configuration file according to the following convention: [base_user_empty_password](base_user_empty_password/) | 18.0.1.0.0 | [![grindtildeath](https://github.com/grindtildeath.png?size=30px)](https://github.com/grindtildeath) | Allows to empty password of users [//]: # (end addons) diff --git a/auth_api_key_group/README.rst b/auth_api_key_group/README.rst new file mode 100644 index 0000000000..3ca55dcd11 --- /dev/null +++ b/auth_api_key_group/README.rst @@ -0,0 +1,99 @@ +================== +Auth API key group +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0c31510542f8db0a00b4350e1c264507309a97ecdfbf7b53e0e0bfb6572f0782 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github + :target: https://github.com/OCA/server-auth/tree/18.0/auth_api_key_group + :alt: OCA/server-auth +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-auth_api_key_group + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allow grouping API keys together. + +Grouping per se does nothing. This feature is supposed to be used by +other modules to limit access to services or records based on groups of +keys. + +The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp. + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp + +Contributors +------------ + +- Simone Orsi +- Son Ho sonhd@trobz.com +- Thien Vo Hong + +Other credits +------------- + +The migration of this module from 16.0 to 17.0 was financially supported +by Camptocamp + +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. + +.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px + :target: https://github.com/simahawk + :alt: simahawk + +Current `maintainer `__: + +|maintainer-simahawk| + +This module is part of the `OCA/server-auth `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/auth_api_key_group/__init__.py b/auth_api_key_group/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/auth_api_key_group/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/auth_api_key_group/__manifest__.py b/auth_api_key_group/__manifest__.py new file mode 100644 index 0000000000..4afbc8f61d --- /dev/null +++ b/auth_api_key_group/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Auth API key group", + "summary": """ +Allow grouping API keys together. + +Grouping per se does nothing. This feature is supposed to be used by other modules +to limit access to services or records based on groups of keys. + """, + "version": "18.0.1.0.0", + "development_status": "Beta", + "license": "LGPL-3", + "website": "https://github.com/OCA/server-auth", + "author": "Camptocamp,Odoo Community Association (OCA)", + "maintainers": ["simahawk"], + "depends": ["auth_api_key"], + "data": [ + "security/ir.model.access.csv", + "views/auth_api_key_view.xml", + "views/auth_api_key_group_view.xml", + ], +} diff --git a/auth_api_key_group/i18n/auth_api_key_group.pot b/auth_api_key_group/i18n/auth_api_key_group.pot new file mode 100644 index 0000000000..bf8df06705 --- /dev/null +++ b/auth_api_key_group/i18n/auth_api_key_group.pot @@ -0,0 +1,80 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_api_key_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: auth_api_key_group +#: model:ir.model,name:auth_api_key_group.model_auth_api_key +msgid "API Key" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model,name:auth_api_key_group.model_auth_api_key_group +msgid "API Key auth group" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__auth_api_key_ids +msgid "API Keys" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.actions.act_window,name:auth_api_key_group.auth_api_key_group_act_window +#: model:ir.ui.menu,name:auth_api_key_group.auth_api_key_group_menu +msgid "Auth Api Key Groups" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key__auth_api_key_group_ids +msgid "Auth Groups" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__code +msgid "Code" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__create_uid +msgid "Created by" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__create_date +msgid "Created on" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__display_name +msgid "Display Name" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__id +msgid "ID" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__write_date +msgid "Last Updated on" +msgstr "" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__name +msgid "Name" +msgstr "" diff --git a/auth_api_key_group/i18n/it.po b/auth_api_key_group/i18n/it.po new file mode 100644 index 0000000000..0509a5a2a9 --- /dev/null +++ b/auth_api_key_group/i18n/it.po @@ -0,0 +1,86 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_api_key_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-03 12:43+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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.17\n" + +#. module: auth_api_key_group +#: model:ir.model,name:auth_api_key_group.model_auth_api_key +msgid "API Key" +msgstr "Chiave API" + +#. module: auth_api_key_group +#: model:ir.model,name:auth_api_key_group.model_auth_api_key_group +msgid "API Key auth group" +msgstr "Gruppo autorizzazione chiave API" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__auth_api_key_ids +msgid "API Keys" +msgstr "Chiavi API" + +#. module: auth_api_key_group +#: model:ir.actions.act_window,name:auth_api_key_group.auth_api_key_group_act_window +#: model:ir.ui.menu,name:auth_api_key_group.auth_api_key_group_menu +msgid "Auth Api Key Groups" +msgstr "Gruppi autorizzazione chiave API" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key__auth_api_key_group_ids +msgid "Auth Groups" +msgstr "Gruppi autorizzazione" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__code +msgid "Code" +msgstr "Codice" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__id +msgid "ID" +msgstr "ID" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: auth_api_key_group +#: model:ir.model.fields,field_description:auth_api_key_group.field_auth_api_key_group__name +msgid "Name" +msgstr "Nome" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/auth_api_key_group/models/__init__.py b/auth_api_key_group/models/__init__.py new file mode 100644 index 0000000000..4f2457794f --- /dev/null +++ b/auth_api_key_group/models/__init__.py @@ -0,0 +1,2 @@ +from . import auth_api_key +from . import auth_api_key_group diff --git a/auth_api_key_group/models/auth_api_key.py b/auth_api_key_group/models/auth_api_key.py new file mode 100644 index 0000000000..46ff9ae907 --- /dev/null +++ b/auth_api_key_group/models/auth_api_key.py @@ -0,0 +1,18 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + + +from odoo import fields, models + + +class AuthApiKey(models.Model): + _inherit = "auth.api.key" + + auth_api_key_group_ids = fields.Many2many( + comodel_name="auth.api.key.group", + relation="auth_api_key_group_rel", + column1="key_id", + column2="group_id", + string="Auth Groups", + ) diff --git a/auth_api_key_group/models/auth_api_key_group.py b/auth_api_key_group/models/auth_api_key_group.py new file mode 100644 index 0000000000..1887287a9b --- /dev/null +++ b/auth_api_key_group/models/auth_api_key_group.py @@ -0,0 +1,23 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + + +from odoo import fields, models + + +class AuthApiKeyGroup(models.Model): + """Group API keys together.""" + + _name = "auth.api.key.group" + _description = "API Key auth group" + + name = fields.Char(required=True) + code = fields.Char(required=True) + auth_api_key_ids = fields.Many2many( + comodel_name="auth.api.key", + relation="auth_api_key_group_rel", + column1="group_id", + column2="key_id", + string="API Keys", + ) diff --git a/auth_api_key_group/pyproject.toml b/auth_api_key_group/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/auth_api_key_group/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/auth_api_key_group/readme/CONTRIBUTORS.md b/auth_api_key_group/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..80001d8594 --- /dev/null +++ b/auth_api_key_group/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Simone Orsi \<\> +- Son Ho +- Thien Vo Hong \<\> diff --git a/auth_api_key_group/readme/CREDITS.md b/auth_api_key_group/readme/CREDITS.md new file mode 100644 index 0000000000..2683261617 --- /dev/null +++ b/auth_api_key_group/readme/CREDITS.md @@ -0,0 +1 @@ +The migration of this module from 16.0 to 17.0 was financially supported by Camptocamp diff --git a/auth_api_key_group/readme/DESCRIPTION.md b/auth_api_key_group/readme/DESCRIPTION.md new file mode 100644 index 0000000000..e2039b5481 --- /dev/null +++ b/auth_api_key_group/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +Allow grouping API keys together. + +Grouping per se does nothing. This feature is supposed to be used by +other modules to limit access to services or records based on groups of +keys. + +The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp. diff --git a/auth_api_key_group/security/ir.model.access.csv b/auth_api_key_group/security/ir.model.access.csv new file mode 100644 index 0000000000..d245cf24cf --- /dev/null +++ b/auth_api_key_group/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_auth_api_key_group,access_auth_api_key_group,model_auth_api_key_group,base.group_system,1,1,1,1 diff --git a/auth_api_key_group/static/description/icon.png b/auth_api_key_group/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/auth_api_key_group/static/description/icon.png differ diff --git a/auth_api_key_group/static/description/index.html b/auth_api_key_group/static/description/index.html new file mode 100644 index 0000000000..d3f61150f3 --- /dev/null +++ b/auth_api_key_group/static/description/index.html @@ -0,0 +1,438 @@ + + + + + +Auth API key group + + + +
+

Auth API key group

+ + +

Beta License: LGPL-3 OCA/server-auth Translate me on Weblate Try me on Runboat

+

Allow grouping API keys together.

+

Grouping per se does nothing. This feature is supposed to be used by +other modules to limit access to services or records based on groups of +keys.

+

The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp.

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 16.0 to 17.0 was financially supported +by Camptocamp

+
+
+

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.

+

Current maintainer:

+

simahawk

+

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

+

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

+
+
+
+ + diff --git a/auth_api_key_group/tests/__init__.py b/auth_api_key_group/tests/__init__.py new file mode 100644 index 0000000000..f831d70c99 --- /dev/null +++ b/auth_api_key_group/tests/__init__.py @@ -0,0 +1 @@ +from . import test_auth_api_key_group diff --git a/auth_api_key_group/tests/test_auth_api_key_group.py b/auth_api_key_group/tests/test_auth_api_key_group.py new file mode 100644 index 0000000000..846bc9750b --- /dev/null +++ b/auth_api_key_group/tests/test_auth_api_key_group.py @@ -0,0 +1,46 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + + +from odoo.tests.common import TransactionCase + + +class TestAuthApiKey(TransactionCase): + @classmethod + def setUpClass(cls, *args, **kwargs): + super().setUpClass(*args, **kwargs) + cls.AuthApiKey = cls.env["auth.api.key"] + cls.AuthApiKeyGroup = cls.env["auth.api.key.group"] + cls.demo_user = cls.env.ref("base.user_demo") + cls.api_key1 = cls.AuthApiKey.create( + {"name": "One", "user_id": cls.demo_user.id, "key": "one"} + ) + cls.api_key2 = cls.AuthApiKey.create( + {"name": "Two", "user_id": cls.demo_user.id, "key": "two"} + ) + cls.api_key3 = cls.AuthApiKey.create( + {"name": "Three", "user_id": cls.demo_user.id, "key": "three"} + ) + cls.api_key_group1 = cls.AuthApiKeyGroup.create( + { + "name": "G One", + "code": "g-one", + "auth_api_key_ids": [(6, 0, (cls.api_key1 + cls.api_key2).ids)], + } + ) + cls.api_key_group2 = cls.AuthApiKeyGroup.create( + { + "name": "G Two", + "code": "g-two", + "auth_api_key_ids": [(6, 0, cls.api_key3.ids)], + } + ) + + def test_relations(self): + self.assertIn(self.api_key_group1, self.api_key1.auth_api_key_group_ids) + self.assertIn(self.api_key_group1, self.api_key2.auth_api_key_group_ids) + self.assertNotIn(self.api_key_group1, self.api_key3.auth_api_key_group_ids) + self.assertIn(self.api_key_group2, self.api_key3.auth_api_key_group_ids) + self.assertNotIn(self.api_key_group2, self.api_key1.auth_api_key_group_ids) + self.assertNotIn(self.api_key_group2, self.api_key1.auth_api_key_group_ids) diff --git a/auth_api_key_group/views/auth_api_key_group_view.xml b/auth_api_key_group/views/auth_api_key_group_view.xml new file mode 100644 index 0000000000..92e4203c21 --- /dev/null +++ b/auth_api_key_group/views/auth_api_key_group_view.xml @@ -0,0 +1,44 @@ + + + + auth.api.key.group.form (in auth_api_key_group) + auth.api.key.group + +
+ + +
+
+
+ + auth.api.key.group.list (in auth_api_key_group) + auth.api.key.group + + + + + + + + + Auth Api Key Groups + auth.api.key.group + list,form + [] + {} + + + Auth Api Key Groups + + + + +
diff --git a/auth_api_key_group/views/auth_api_key_view.xml b/auth_api_key_group/views/auth_api_key_view.xml new file mode 100644 index 0000000000..a7c7192f29 --- /dev/null +++ b/auth_api_key_group/views/auth_api_key_view.xml @@ -0,0 +1,12 @@ + + + + auth.api.key + + + + + + + + diff --git a/auth_api_key_server_env/README.rst b/auth_api_key_server_env/README.rst new file mode 100644 index 0000000000..b059af3baf --- /dev/null +++ b/auth_api_key_server_env/README.rst @@ -0,0 +1,94 @@ +=============================== +Auth API key server environment +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5be14139031905305a9386404cbb8fe634b8be05ce3e318cd6c183619c52746c + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github + :target: https://github.com/OCA/server-auth/tree/18.0/auth_api_key_server_env + :alt: OCA/server-auth +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-auth_api_key_server_env + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Configure api keys via server env. + +This can be very useful to avoid mixing your keys between your various +environments when restoring databases. All you have to do is to add a +new section to your configuration file according to the following +convention: + +.. code:: ini + + [api_key_] + key=my_api_key + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp + +Contributors +------------ + +- Simone Orsi +- Florian da Costa +- Thien Vo Hong + +Other credits +------------- + +The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp. + +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-auth `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/auth_api_key_server_env/__init__.py b/auth_api_key_server_env/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/auth_api_key_server_env/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/auth_api_key_server_env/__manifest__.py b/auth_api_key_server_env/__manifest__.py new file mode 100644 index 0000000000..c81ff89a49 --- /dev/null +++ b/auth_api_key_server_env/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Auth API key server environment", + "summary": """ +Configure api keys via server env. + +This can be very useful to avoid mixing your keys between your various +environments when restoring databases. All you have to do is to add a new +section to your configuration file according to the following convention: + """, + "version": "18.0.1.0.0", + "development_status": "Production/Stable", + "license": "LGPL-3", + "website": "https://github.com/OCA/server-auth", + "author": "Camptocamp,Odoo Community Association (OCA)", + "depends": ["auth_api_key", "server_environment"], + "data": [], +} diff --git a/auth_api_key_server_env/i18n/auth_api_key_server_env.pot b/auth_api_key_server_env/i18n/auth_api_key_server_env.pot new file mode 100644 index 0000000000..2886b752cc --- /dev/null +++ b/auth_api_key_server_env/i18n/auth_api_key_server_env.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_api_key_server_env +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: auth_api_key_server_env +#: model:ir.model,name:auth_api_key_server_env.model_auth_api_key +msgid "API Key" +msgstr "" + +#. module: auth_api_key_server_env +#: model:ir.model.fields,field_description:auth_api_key_server_env.field_auth_api_key__server_env_defaults +msgid "Server Env Defaults" +msgstr "" + +#. module: auth_api_key_server_env +#: model:ir.model.fields,field_description:auth_api_key_server_env.field_auth_api_key__tech_name +msgid "Tech Name" +msgstr "" + +#. module: auth_api_key_server_env +#: model:ir.model.fields,help:auth_api_key_server_env.field_auth_api_key__tech_name +msgid "Unique name for technical purposes. Eg: server env keys." +msgstr "" diff --git a/auth_api_key_server_env/i18n/it.po b/auth_api_key_server_env/i18n/it.po new file mode 100644 index 0000000000..81dba352b5 --- /dev/null +++ b/auth_api_key_server_env/i18n/it.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_api_key_server_env +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-04 22:36+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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.17\n" + +#. module: auth_api_key_server_env +#: model:ir.model,name:auth_api_key_server_env.model_auth_api_key +msgid "API Key" +msgstr "Chiave API" + +#. module: auth_api_key_server_env +#: model:ir.model.fields,field_description:auth_api_key_server_env.field_auth_api_key__server_env_defaults +msgid "Server Env Defaults" +msgstr "Server ambiente predefinito" + +#. module: auth_api_key_server_env +#: model:ir.model.fields,field_description:auth_api_key_server_env.field_auth_api_key__tech_name +msgid "Tech Name" +msgstr "Nome tecnico" + +#. module: auth_api_key_server_env +#: model:ir.model.fields,help:auth_api_key_server_env.field_auth_api_key__tech_name +msgid "Unique name for technical purposes. Eg: server env keys." +msgstr "Nome univoco per motivi tecnici. Es: chiavi server ambiente." diff --git a/auth_api_key_server_env/models/__init__.py b/auth_api_key_server_env/models/__init__.py new file mode 100644 index 0000000000..6dfe3f790b --- /dev/null +++ b/auth_api_key_server_env/models/__init__.py @@ -0,0 +1 @@ +from . import auth_api_key diff --git a/auth_api_key_server_env/models/auth_api_key.py b/auth_api_key_server_env/models/auth_api_key.py new file mode 100644 index 0000000000..64db93d4e8 --- /dev/null +++ b/auth_api_key_server_env/models/auth_api_key.py @@ -0,0 +1,29 @@ +# Copyright 2018 ACSONE SA/NV +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + + +from odoo import models + + +class AuthApiKey(models.Model): + _name = "auth.api.key" + _inherit = ["auth.api.key", "server.env.techname.mixin", "server.env.mixin"] + + def _server_env_section_name(self): + """Name of the section in the configuration files + We override the default implementation to keep the compatibility + with the previous implementation of auth_api_key. The section name + into the configuration file must be formatted as + 'api_key_{name}' + """ + self.ensure_one() + return f"api_key_{getattr(self, self._server_env_section_name_field)}" + + @property + def _server_env_fields(self): + base_fields = super()._server_env_fields + api_key_fields = {"key": {}} + api_key_fields.update(base_fields) + return api_key_fields diff --git a/auth_api_key_server_env/pyproject.toml b/auth_api_key_server_env/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/auth_api_key_server_env/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/auth_api_key_server_env/readme/CONTRIBUTORS.md b/auth_api_key_server_env/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..28d0ec9385 --- /dev/null +++ b/auth_api_key_server_env/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Simone Orsi \<\> +- Florian da Costa \<\> +- Thien Vo Hong \<\> diff --git a/auth_api_key_server_env/readme/CREDITS.md b/auth_api_key_server_env/readme/CREDITS.md new file mode 100644 index 0000000000..83b3ec91f7 --- /dev/null +++ b/auth_api_key_server_env/readme/CREDITS.md @@ -0,0 +1 @@ +The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp. diff --git a/auth_api_key_server_env/readme/DESCRIPTION.md b/auth_api_key_server_env/readme/DESCRIPTION.md new file mode 100644 index 0000000000..fd3f7ddf12 --- /dev/null +++ b/auth_api_key_server_env/readme/DESCRIPTION.md @@ -0,0 +1,11 @@ +Configure api keys via server env. + +This can be very useful to avoid mixing your keys between your various +environments when restoring databases. All you have to do is to add a +new section to your configuration file according to the following +convention: + +``` ini +[api_key_] +key=my_api_key +``` diff --git a/auth_api_key_server_env/static/description/icon.png b/auth_api_key_server_env/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/auth_api_key_server_env/static/description/icon.png differ diff --git a/auth_api_key_server_env/static/description/index.html b/auth_api_key_server_env/static/description/index.html new file mode 100644 index 0000000000..4353042a6d --- /dev/null +++ b/auth_api_key_server_env/static/description/index.html @@ -0,0 +1,439 @@ + + + + + +Auth API key server environment + + + +
+

Auth API key server environment

+ + +

Production/Stable License: LGPL-3 OCA/server-auth Translate me on Weblate Try me on Runboat

+

Configure api keys via server env.

+

This can be very useful to avoid mixing your keys between your various +environments when restoring databases. All you have to do is to add a +new section to your configuration file according to the following +convention:

+
+[api_key_<record.tech_name>]
+key=my_api_key
+
+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp.

+
+
+

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-auth project on GitHub.

+

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

+
+
+
+ + diff --git a/auth_api_key_server_env/tests/__init__.py b/auth_api_key_server_env/tests/__init__.py new file mode 100644 index 0000000000..56e3e32a3a --- /dev/null +++ b/auth_api_key_server_env/tests/__init__.py @@ -0,0 +1 @@ +from . import test_auth_api_key diff --git a/auth_api_key_server_env/tests/test_auth_api_key.py b/auth_api_key_server_env/tests/test_auth_api_key.py new file mode 100644 index 0000000000..1444349a79 --- /dev/null +++ b/auth_api_key_server_env/tests/test_auth_api_key.py @@ -0,0 +1,37 @@ +# Copyright 2018 ACSONE SA/NV +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +from odoo.exceptions import ValidationError +from odoo.tests.common import TransactionCase + +from odoo.addons.server_environment import serv_config + + +class TestAuthApiKey(TransactionCase): + @classmethod + def setUpClass(cls, *args, **kwargs): + super().setUpClass(*args, **kwargs) + cls.AuthApiKey = cls.env["auth.api.key"] + cls.demo_user = cls.env.ref("base.user_demo") + cls.api_key_from_env = cls.AuthApiKey.create( + { + "name": "From Env", + "key": "dummy", + "user_id": cls.demo_user.id, + "tech_name": "test_env", + } + ) + cls.api_key_from_env.invalidate_recordset() + serv_config.add_section("api_key_test_env") + serv_config.set("api_key_test_env", "key", "api_key_from_env") + + def test_lookup_key_from_env(self): + self.assertEqual( + self.env["auth.api.key"]._retrieve_uid_from_api_key("api_key_from_env"), + self.demo_user.id, + ) + with self.assertRaises(ValidationError): + # dummy key must be replace with the one from env and + # therefore should be unusable + self.env["auth.api.key"]._retrieve_uid_from_api_key("dummy") diff --git a/setup/_metapackage/pyproject.toml b/setup/_metapackage/pyproject.toml index b5735c8fa0..0acddf920c 100644 --- a/setup/_metapackage/pyproject.toml +++ b/setup/_metapackage/pyproject.toml @@ -1,8 +1,10 @@ [project] name = "odoo-addons-oca-server-auth" -version = "18.0.20241011.1" +version = "18.0.20241019.1" dependencies = [ "odoo-addon-auth_api_key==18.0.*", + "odoo-addon-auth_api_key_group==18.0.*", + "odoo-addon-auth_api_key_server_env==18.0.*", "odoo-addon-base_user_empty_password==18.0.*", ] classifiers=[