diff --git a/auth_api_key_group/README.rst b/auth_api_key_group/README.rst new file mode 100644 index 0000000000..2d0181b8ab --- /dev/null +++ b/auth_api_key_group/README.rst @@ -0,0 +1,89 @@ +================== +Auth API key group +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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/15.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-15-0/server-auth-15-0-auth_api_key_group + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/251/15.0 + :alt: Try me on Runbot + +|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. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptcamp + +Contributors +~~~~~~~~~~~~ + +* Simone Orsi + +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..8ac634aad9 --- /dev/null +++ b/auth_api_key_group/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2021 Camptcamp 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": "16.0.1.0.0", + "license": "LGPL-3", + "website": "https://github.com/OCA/server-auth", + "author": "Camptcamp,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..05a8812a79 --- /dev/null +++ b/auth_api_key_group/i18n/auth_api_key_group.pot @@ -0,0 +1,85 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_api_key_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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____last_update +msgid "Last Modified on" +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/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..661e3c1a41 --- /dev/null +++ b/auth_api_key_group/models/auth_api_key.py @@ -0,0 +1,19 @@ +# Copyright 2021 Camptcamp 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..28f34f5e85 --- /dev/null +++ b/auth_api_key_group/models/auth_api_key_group.py @@ -0,0 +1,23 @@ +# Copyright 2021 Camptcamp 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/readme/CONTRIBUTORS.rst b/auth_api_key_group/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..f1c71bce18 --- /dev/null +++ b/auth_api_key_group/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Simone Orsi diff --git a/auth_api_key_group/readme/DESCRIPTION.rst b/auth_api_key_group/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..1becef6070 --- /dev/null +++ b/auth_api_key_group/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +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. 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..937b94ec67 --- /dev/null +++ b/auth_api_key_group/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +Auth API key group + + + +
+

Auth API key group

+ + +

Alpha License: LGPL-3 OCA/server-auth Translate me on Weblate Try me on Runbot

+

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.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Camptcamp
  • +
+
+ +
+

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..75581bbf16 --- /dev/null +++ b/auth_api_key_group/tests/test_auth_api_key_group.py @@ -0,0 +1,46 @@ +# Copyright 2021 Camptcamp 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..267284d851 --- /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.tree (in auth_api_key_group) + auth.api.key.group + + + + + + + + + Auth Api Key Groups + auth.api.key.group + tree,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/setup/auth_api_key_group/odoo/addons/auth_api_key_group b/setup/auth_api_key_group/odoo/addons/auth_api_key_group new file mode 120000 index 0000000000..4cda5ca1f9 --- /dev/null +++ b/setup/auth_api_key_group/odoo/addons/auth_api_key_group @@ -0,0 +1 @@ +../../../../auth_api_key_group \ No newline at end of file diff --git a/setup/auth_api_key_group/setup.py b/setup/auth_api_key_group/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/auth_api_key_group/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)