diff --git a/README.md b/README.md index 0a41fe8a15..c075c8da22 100644 --- a/README.md +++ b/README.md @@ -23,15 +23,17 @@ addon | version | maintainers | summary --- | --- | --- | --- [auth_admin_passkey](auth_admin_passkey/) | 16.0.1.0.0 | | Allows system administrator to authenticate with any account [auth_api_key](auth_api_key/) | 16.0.1.0.0 | | Authenticate http requests from an API key +[auth_api_key_group](auth_api_key_group/) | 16.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/) | 16.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: [auth_jwt](auth_jwt/) | 16.0.1.1.0 | [![sbidoul](https://github.com/sbidoul.png?size=30px)](https://github.com/sbidoul) | JWT bearer token authentication. [auth_jwt_demo](auth_jwt_demo/) | 16.0.1.1.1 | [![sbidoul](https://github.com/sbidoul.png?size=30px)](https://github.com/sbidoul) | Test/demo module for auth_jwt. [auth_jwt_server_env](auth_jwt_server_env/) | 16.0.1.0.0 | | This addon adds auth.jwt.validator fields to server env [auth_ldaps](auth_ldaps/) | 16.0.1.0.0 | | Allows to use LDAP over SSL authentication +[auth_oauth_multi_token](auth_oauth_multi_token/) | 16.0.1.0.0 | | Allow multiple connection with the same OAuth account [auth_oauth_ropc](auth_oauth_ropc/) | 16.0.1.0.0 | | Allow to login with OAuth Resource Owner Password Credentials Grant -[auth_oidc](auth_oidc/) | 16.0.1.0.2 | [![sbidoul](https://github.com/sbidoul.png?size=30px)](https://github.com/sbidoul) | Allow users to login through OpenID Connect Provider +[auth_oidc](auth_oidc/) | 16.0.1.1.1 | [![sbidoul](https://github.com/sbidoul.png?size=30px)](https://github.com/sbidoul) | Allow users to login through OpenID Connect Provider [auth_oidc_environment](auth_oidc_environment/) | 16.0.1.0.0 | | This module allows to use server env for OIDC configuration -[auth_saml](auth_saml/) | 16.0.1.0.3 | [![vincent-hatakeyama](https://github.com/vincent-hatakeyama.png?size=30px)](https://github.com/vincent-hatakeyama) | SAML2 Authentication +[auth_saml](auth_saml/) | 16.0.1.0.4 | [![vincent-hatakeyama](https://github.com/vincent-hatakeyama.png?size=30px)](https://github.com/vincent-hatakeyama) | SAML2 Authentication [auth_session_timeout](auth_session_timeout/) | 16.0.1.0.0 | | This module disable all inactive sessions since a given delay [auth_signup_verify_email](auth_signup_verify_email/) | 16.0.1.0.0 | | Force uninvited users to use a good email for signup [auth_user_case_insensitive](auth_user_case_insensitive/) | 16.0.1.0.0 | | Makes the user login field case insensitive @@ -41,6 +43,8 @@ addon | version | maintainers | summary [users_ldap_groups](users_ldap_groups/) | 16.0.1.0.0 | | Adds user accounts to groups based on rules defined by the administrator. [users_ldap_mail](users_ldap_mail/) | 16.0.1.0.0 | [![joao-p-marques](https://github.com/joao-p-marques.png?size=30px)](https://github.com/joao-p-marques) | LDAP mapping for user name and e-mail [users_ldap_populate](users_ldap_populate/) | 16.0.1.0.0 | [![joao-p-marques](https://github.com/joao-p-marques.png?size=30px)](https://github.com/joao-p-marques) | LDAP Populate +[vault](vault/) | 16.0.1.0.0 | | Password vault integration in Odoo +[vault_share](vault_share/) | 16.0.1.0.0 | | Implementation of a mechanism to share secrets [//]: # (end addons) diff --git a/auth_admin_passkey/i18n/it.po b/auth_admin_passkey/i18n/it.po index 23262c5932..12d8de629a 100644 --- a/auth_admin_passkey/i18n/it.po +++ b/auth_admin_passkey/i18n/it.po @@ -9,15 +9,15 @@ msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2017-08-01 02:43+0000\n" -"PO-Revision-Date: 2022-02-21 12:17+0000\n" -"Last-Translator: Simone Rubino \n" +"PO-Revision-Date: 2024-01-03 14:33+0000\n" +"Last-Translator: mymage \n" "Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\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.3.2\n" +"X-Generator: Weblate 4.17\n" #. module: auth_admin_passkey #. odoo-python @@ -40,11 +40,20 @@ msgid "" "- Login date : %(login_date)s\n" "\n" msgstr "" +"L'utente amministratore di sistemaha usato la sua passkey per accedere con " +"%(login)s.\n" +"\n" +"\n" +"\n" +"Informazioni tecniche di seguito: \n" +"\n" +"- Data accesso : %(login_date)s\n" +"\n" #. module: auth_admin_passkey #: model:ir.model,name:auth_admin_passkey.model_res_users msgid "User" -msgstr "" +msgstr "Utente" #, python-format #~ msgid "
User with login '%s' has the same password as you.
" diff --git a/auth_api_key_group/README.rst b/auth_api_key_group/README.rst new file mode 100644 index 0000000000..ed4520bd51 --- /dev/null +++ b/auth_api_key_group/README.rst @@ -0,0 +1,87 @@ +================== +Auth API key group +================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e231a34a3fe2c3a2a8c78305131ba9e90af3725f3cf0b0878d313439f511f6fe + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.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-16-0/server-auth-16-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=16.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. + +**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 +~~~~~~~ + +* 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..2aff7a6ef4 --- /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 16.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..2a52d4df14 --- /dev/null +++ b/auth_api_key_group/static/description/index.html @@ -0,0 +1,424 @@ + + + + + +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.

+

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

+
    +
  • 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/auth_api_key_server_env/i18n/it.po b/auth_api_key_server_env/i18n/it.po index d89bdd12d3..35b514e0af 100644 --- a/auth_api_key_server_env/i18n/it.po +++ b/auth_api_key_server_env/i18n/it.po @@ -6,30 +6,32 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2024-01-03 14:33+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 "" +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 "" +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 "" +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 "" +msgstr "Nome univoco per motivi tecnici. Es: chiavi server ambiente." diff --git a/auth_jwt/i18n/it.po b/auth_jwt/i18n/it.po index 9336d05128..9d3c3da001 100644 --- a/auth_jwt/i18n/it.po +++ b/auth_jwt/i18n/it.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2023-12-15 13:34+0000\n" -"Last-Translator: Riccardo Bellanova \n" +"PO-Revision-Date: 2024-01-29 11:35+0000\n" +"Last-Translator: Francesco Foresti \n" "Language-Team: none\n" "Language: it\n" "MIME-Version: 1.0\n" @@ -80,9 +80,8 @@ msgstr "Path cookie" #. module: auth_jwt #: model:ir.model.fields,field_description:auth_jwt.field_auth_jwt_validator__cookie_secure -#, fuzzy msgid "Cookie Secure" -msgstr "Cookie Secure" +msgstr "Cookie secure" #. module: auth_jwt #: model:ir.model.fields,field_description:auth_jwt.field_auth_jwt_validator__create_uid @@ -121,9 +120,8 @@ msgstr "ES512 - ECDSA usando SHA-512" #. module: auth_jwt #: model:ir.model.fields.selection,name:auth_jwt.selection__auth_jwt_validator__partner_id_strategy__email -#, fuzzy msgid "From email claim" -msgstr "Dalla richiesta email" +msgstr "Da richiesta e-mail" #. module: auth_jwt #: model_terms:ir.ui.view,arch_db:auth_jwt.view_auth_jwt_validator_form @@ -152,21 +150,18 @@ msgstr "Instradamento HTTP" #. module: auth_jwt #: model:ir.model.fields,field_description:auth_jwt.field_auth_jwt_validator__id -#, fuzzy msgid "ID" msgstr "ID" #. module: auth_jwt #: model:ir.model.fields,field_description:auth_jwt.field_auth_jwt_validator__issuer -#, fuzzy msgid "Issuer" -msgstr "Issuer" +msgstr "Segnalatore" #. module: auth_jwt #: model_terms:ir.ui.view,arch_db:auth_jwt.view_auth_jwt_validator_form -#, fuzzy msgid "JWK URI" -msgstr "JWK URI" +msgstr "URI JWK" #. module: auth_jwt #: model:ir.model,name:auth_jwt.model_auth_jwt_validator @@ -197,7 +192,7 @@ msgstr "Ultima modifica il" #. module: auth_jwt #: model:ir.model.fields,field_description:auth_jwt.field_auth_jwt_validator__write_uid msgid "Last Updated by" -msgstr "Ultimo aggiornamento da" +msgstr "Ultimo aggiornamento di" #. module: auth_jwt #: model:ir.model.fields,field_description:auth_jwt.field_auth_jwt_validator__write_date @@ -248,7 +243,6 @@ msgstr "PS512 - RSASSA-PSS usando SHA-512 e padding MGF1 con SHA-512" #. module: auth_jwt #: model_terms:ir.ui.view,arch_db:auth_jwt.view_auth_jwt_validator_form -#, fuzzy msgid "Partner" msgstr "Partner" @@ -356,6 +350,5 @@ msgstr "I validatori non devono creare una catena chiusa: {}." #. module: auth_jwt #: model_terms:ir.ui.view,arch_db:auth_jwt.view_auth_jwt_validator_form -#, fuzzy msgid "arch" msgstr "arch" diff --git a/auth_jwt_server_env/i18n/it.po b/auth_jwt_server_env/i18n/it.po index 3c74fdbbf2..5d664490e7 100644 --- a/auth_jwt_server_env/i18n/it.po +++ b/auth_jwt_server_env/i18n/it.po @@ -6,20 +6,22 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2024-01-03 14:33+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_jwt_server_env #: model:ir.model,name:auth_jwt_server_env.model_auth_jwt_validator msgid "JWT Validator Configuration" -msgstr "" +msgstr "Configurazione validatore JWT" #. module: auth_jwt_server_env #: model:ir.model.fields,field_description:auth_jwt_server_env.field_auth_jwt_validator__server_env_defaults msgid "Server Env Defaults" -msgstr "" +msgstr "Server ambiente predefinito" diff --git a/auth_oauth_multi_token/README.rst b/auth_oauth_multi_token/README.rst new file mode 100644 index 0000000000..c7090d1287 --- /dev/null +++ b/auth_oauth_multi_token/README.rst @@ -0,0 +1,94 @@ +================= +OAuth Multi Token +================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5d69848be1a2005788b0912d52d59e788ed05ce24855822272fcdb20489ad6cc + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--auth-lightgray.png?logo=github + :target: https://github.com/OCA/server-auth/tree/16.0/auth_oauth_multi_token + :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-16-0/server-auth-16-0-auth_oauth_multi_token + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the possibility to connect with the same account +on more than one device at the same time. + +All providers are supported (Google, Facebook, Odoo, etc). + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Nothing changes on login action: just select your provider and try to log in. + +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 +~~~~~~~ + +* Florent de Labarre +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Florent de Labarre +* Simone Orsi +* `Tecnativa `__: + + * Jairo Llopis + * Sergio Teruel + +* Stéphane Bidoul +* Dan Tillinghast +* Miku Laitinen + +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_oauth_multi_token/__init__.py b/auth_oauth_multi_token/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/auth_oauth_multi_token/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/auth_oauth_multi_token/__manifest__.py b/auth_oauth_multi_token/__manifest__.py new file mode 100644 index 0000000000..78c1b2fcdd --- /dev/null +++ b/auth_oauth_multi_token/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2016 Florent de Labarre +# Copyright 2017 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +{ + "name": "OAuth Multi Token", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Florent de Labarre, Camptocamp, Odoo Community Association (OCA)", + "summary": """Allow multiple connection with the same OAuth account""", + "category": "Tool", + "website": "https://github.com/OCA/server-auth", + "depends": ["auth_oauth"], + "data": [ + "security/ir.model.access.csv", + "views/auth_oauth_multi_token.xml", + "views/res_users.xml", + ], + "installable": True, +} diff --git a/auth_oauth_multi_token/i18n/auth_oauth_multi_token.pot b/auth_oauth_multi_token/i18n/auth_oauth_multi_token.pot new file mode 100644 index 0000000000..4dced6c5bc --- /dev/null +++ b/auth_oauth_multi_token/i18n/auth_oauth_multi_token.pot @@ -0,0 +1,90 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_oauth_multi_token +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_oauth_multi_token +#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form +msgid "Clear Tokens" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_uid +msgid "Created by" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_date +msgid "Created on" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__display_name +msgid "Display Name" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__id +msgid "ID" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token____last_update +msgid "Last Modified on" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_date +msgid "Last Updated on" +msgstr "" + +#. module: auth_oauth_multi_token +#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form +msgid "Latest Tokens" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_master_uuid +msgid "Master UUID" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_max_token +msgid "Max Number of Simultaneous Connections" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__oauth_access_token +msgid "OAuth Access Token" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_token_ids +msgid "OAuth Tokens" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model,name:auth_oauth_multi_token.model_auth_oauth_multi_token +msgid "OAuth2 Token" +msgstr "" + +#. module: auth_oauth_multi_token +#: model:ir.model,name:auth_oauth_multi_token.model_res_users +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__user_id +msgid "User" +msgstr "" diff --git a/auth_oauth_multi_token/i18n/it.po b/auth_oauth_multi_token/i18n/it.po new file mode 100644 index 0000000000..df18dd38a7 --- /dev/null +++ b/auth_oauth_multi_token/i18n/it.po @@ -0,0 +1,93 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_oauth_multi_token +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-03-14 15:38+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_oauth_multi_token +#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form +msgid "Clear Tokens" +msgstr "Pulisci token" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__id +msgid "ID" +msgstr "ID" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: auth_oauth_multi_token +#: model_terms:ir.ui.view,arch_db:auth_oauth_multi_token.view_users_form +msgid "Latest Tokens" +msgstr "Ulrimi token" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_master_uuid +msgid "Master UUID" +msgstr "UUID master" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_max_token +msgid "Max Number of Simultaneous Connections" +msgstr "Numero massimo di connessioni simultanee" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__oauth_access_token +msgid "OAuth Access Token" +msgstr "Token accesso OAuth" + +#. module: auth_oauth_multi_token +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_res_users__oauth_access_token_ids +msgid "OAuth Tokens" +msgstr "Token OAuth" + +#. module: auth_oauth_multi_token +#: model:ir.model,name:auth_oauth_multi_token.model_auth_oauth_multi_token +msgid "OAuth2 Token" +msgstr "Token OAuth" + +#. module: auth_oauth_multi_token +#: model:ir.model,name:auth_oauth_multi_token.model_res_users +#: model:ir.model.fields,field_description:auth_oauth_multi_token.field_auth_oauth_multi_token__user_id +msgid "User" +msgstr "Utente" diff --git a/auth_oauth_multi_token/models/__init__.py b/auth_oauth_multi_token/models/__init__.py new file mode 100644 index 0000000000..eac3467aa9 --- /dev/null +++ b/auth_oauth_multi_token/models/__init__.py @@ -0,0 +1,2 @@ +from . import auth_oauth_multi_token +from . import res_users diff --git a/auth_oauth_multi_token/models/auth_oauth_multi_token.py b/auth_oauth_multi_token/models/auth_oauth_multi_token.py new file mode 100644 index 0000000000..a1c11f04b8 --- /dev/null +++ b/auth_oauth_multi_token/models/auth_oauth_multi_token.py @@ -0,0 +1,54 @@ +# Copyright 2016 Florent de Labarre +# Copyright 2017 Camptocamp +# Copyright 2021 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import api, fields, models + + +class AuthOauthMultiToken(models.Model): + """Define a set of tokens.""" + + _name = "auth.oauth.multi.token" + _description = "OAuth2 Token" + _order = "id desc" + + oauth_access_token = fields.Char( + string="OAuth Access Token", readonly=True, copy=False + ) + user_id = fields.Many2one( + comodel_name="res.users", + string="User", + required=True, + readonly=True, + index=True, + ondelete="cascade", + ) + + @api.model_create_multi + def create(self, vals_list): + """Override to validate tokens.""" + tokens = super().create(vals_list) + tokens._oauth_validate_multi_token() + return tokens + + @api.model + def _oauth_user_tokens(self, user_id): + """Retrieve tokens for given user. + + :param user_id: Odoo ID of the user + """ + return self.search([("user_id", "=", user_id)]) + + def _oauth_validate_multi_token(self): + """Check current user's token and clear them if max number reached.""" + for token in self: + user_tokens = self._oauth_user_tokens(token.user_id.id) + max_token = token.user_id.oauth_access_max_token + if user_tokens and len(user_tokens) > max_token: + # clear last token + user_tokens[max_token - 1]._oauth_clear_token() + + def _oauth_clear_token(self): + """Disable current token records.""" + self.unlink() diff --git a/auth_oauth_multi_token/models/res_users.py b/auth_oauth_multi_token/models/res_users.py new file mode 100644 index 0000000000..53c4bff115 --- /dev/null +++ b/auth_oauth_multi_token/models/res_users.py @@ -0,0 +1,83 @@ +# Copyright 2016 Florent de Labarre +# Copyright 2017 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +import uuid + +from odoo import api, exceptions, fields, models + +from odoo.addons import base + +base.models.res_users.USER_PRIVATE_FIELDS.append("oauth_master_uuid") + + +class ResUsers(models.Model): + _inherit = "res.users" + + def _generate_oauth_master_uuid(self): + return uuid.uuid4().hex + + oauth_access_token_ids = fields.One2many( + comodel_name="auth.oauth.multi.token", + inverse_name="user_id", + string="OAuth Tokens", + copy=False, + readonly=True, + groups="base.group_system", + ) + oauth_access_max_token = fields.Integer( + string="Max Number of Simultaneous Connections", default=10, required=True + ) + oauth_master_uuid = fields.Char( + string="Master UUID", + copy=False, + readonly=True, + required=True, + default=lambda self: self._generate_oauth_master_uuid(), + ) + + @property + def multi_token_model(self): + return self.env["auth.oauth.multi.token"] + + @api.model + def _auth_oauth_signin(self, provider, validation, params): + """Override to handle sign-in with multi token.""" + res = super()._auth_oauth_signin(provider, validation, params) + + oauth_uid = validation["user_id"] + # Lookup for user by oauth uid and provider + user = self.search( + [("oauth_uid", "=", oauth_uid), ("oauth_provider_id", "=", provider)] + ) + if not user: + raise exceptions.AccessDenied() + user.ensure_one() + # user found and unique: create a token + self.multi_token_model.create( + {"user_id": user.id, "oauth_access_token": params["access_token"]} + ) + return res + + def action_oauth_clear_token(self): + """Inactivate current user tokens.""" + self.mapped("oauth_access_token_ids")._oauth_clear_token() + for res in self: + res.oauth_access_token = False + res.oauth_master_uuid = self._generate_oauth_master_uuid() + + @api.model + def _check_credentials(self, password, env): + """Override to check credentials against multi tokens.""" + try: + return super()._check_credentials(password, env) + except exceptions.AccessDenied: + res = self.multi_token_model.sudo().search( + [("user_id", "=", self.env.uid), ("oauth_access_token", "=", password)] + ) + if not res: + raise + + def _get_session_token_fields(self): + res = super()._get_session_token_fields() + res.remove("oauth_access_token") + return res | {"oauth_master_uuid"} diff --git a/auth_oauth_multi_token/readme/CONFIGURATION.rst b/auth_oauth_multi_token/readme/CONFIGURATION.rst new file mode 100644 index 0000000000..a9542214e8 --- /dev/null +++ b/auth_oauth_multi_token/readme/CONFIGURATION.rst @@ -0,0 +1,5 @@ +On users' form you can set the number of maximum simultaneous connections. + +By default 10 connections are allowed. + +From there you can also clear / inactivate existing tokens. diff --git a/auth_oauth_multi_token/readme/CONTRIBUTORS.rst b/auth_oauth_multi_token/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..59bc0837d2 --- /dev/null +++ b/auth_oauth_multi_token/readme/CONTRIBUTORS.rst @@ -0,0 +1,10 @@ +* Florent de Labarre +* Simone Orsi +* `Tecnativa `__: + + * Jairo Llopis + * Sergio Teruel + +* Stéphane Bidoul +* Dan Tillinghast +* Miku Laitinen diff --git a/auth_oauth_multi_token/readme/DESCRIPTION.rst b/auth_oauth_multi_token/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..2a1cb15f8a --- /dev/null +++ b/auth_oauth_multi_token/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module adds the possibility to connect with the same account +on more than one device at the same time. + +All providers are supported (Google, Facebook, Odoo, etc). diff --git a/auth_oauth_multi_token/readme/USAGE.rst b/auth_oauth_multi_token/readme/USAGE.rst new file mode 100644 index 0000000000..7d01facaa8 --- /dev/null +++ b/auth_oauth_multi_token/readme/USAGE.rst @@ -0,0 +1 @@ +Nothing changes on login action: just select your provider and try to log in. diff --git a/auth_oauth_multi_token/security/ir.model.access.csv b/auth_oauth_multi_token/security/ir.model.access.csv new file mode 100644 index 0000000000..4c0a15f46d --- /dev/null +++ b/auth_oauth_multi_token/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_oauth_multi_token_admin,auth_oauth_multi_token admin,model_auth_oauth_multi_token,base.group_system,1,1,1,1 diff --git a/auth_oauth_multi_token/static/description/icon.png b/auth_oauth_multi_token/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/auth_oauth_multi_token/static/description/icon.png differ diff --git a/auth_oauth_multi_token/static/description/index.html b/auth_oauth_multi_token/static/description/index.html new file mode 100644 index 0000000000..836e8b8f60 --- /dev/null +++ b/auth_oauth_multi_token/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +OAuth Multi Token + + + +
+

OAuth Multi Token

+ + +

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

+

This module adds the possibility to connect with the same account +on more than one device at the same time.

+

All providers are supported (Google, Facebook, Odoo, etc).

+

Table of contents

+ +
+

Usage

+

Nothing changes on login action: just select your provider and try to log in.

+
+
+

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

+
    +
  • Florent de Labarre
  • +
  • Camptocamp
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/auth_oauth_multi_token/tests/__init__.py b/auth_oauth_multi_token/tests/__init__.py new file mode 100644 index 0000000000..fb016763d8 --- /dev/null +++ b/auth_oauth_multi_token/tests/__init__.py @@ -0,0 +1 @@ +from . import test_multi_token diff --git a/auth_oauth_multi_token/tests/test_multi_token.py b/auth_oauth_multi_token/tests/test_multi_token.py new file mode 100644 index 0000000000..f63affd9b8 --- /dev/null +++ b/auth_oauth_multi_token/tests/test_multi_token.py @@ -0,0 +1,91 @@ +# Copyright 2017 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +import json + +from odoo import exceptions +from odoo.tests.common import TransactionCase + + +class TestMultiToken(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.token_model = cls.env["auth.oauth.multi.token"] + cls.provider_google = cls.env.ref("auth_oauth.provider_google") + cls.user_model = cls.env["res.users"].with_context( + tracking_disable=True, no_reset_password=True + ) + cls.user = cls.user_model.create( + { + "name": "John Doe", + "login": "johndoe", + "oauth_uid": "oauth_uid_johndoe", + "oauth_provider_id": cls.provider_google.id, + } + ) + + def _fake_params(self, **kw): + params = { + "state": json.dumps({"t": "FAKE_TOKEN"}), + "access_token": "FAKE_ACCESS_TOKEN", + } + params.update(kw) + return params + + def test_no_provider_no_access(self): + validation = { + "user_id": "oauth_uid_no_one", + } + params = self._fake_params() + with self.assertRaises(exceptions.AccessDenied): + self.user_model._auth_oauth_signin( + self.provider_google.id, validation, params + ) + + def _test_one_token(self): + validation = { + "user_id": "oauth_uid_johndoe", + } + params = self._fake_params() + login = self.user_model._auth_oauth_signin( + self.provider_google.id, validation, params + ) + self.assertEqual(login, "johndoe") + + def test_access_one_token(self): + # no token yet + self.assertFalse(self.user.oauth_access_token_ids) + self._test_one_token() + token_count = 1 + self.assertEqual(len(self.user.oauth_access_token_ids), token_count) + self.assertEqual( + len(self.token_model._oauth_user_tokens(self.user.id)), token_count + ) + + def test_access_multi_token(self): + # no token yet + self.assertFalse(self.user.oauth_access_token_ids) + # use as many token as max allowed + for token_count in range(1, self.user.oauth_access_max_token + 1): + self._test_one_token() + self.assertEqual(len(self.user.oauth_access_token_ids), token_count) + self.assertEqual( + len(self.token_model._oauth_user_tokens(self.user.id)), token_count + ) + # exceed the number + self._test_one_token() + # token count does not exceed max number + self.assertEqual( + len(self.user.oauth_access_token_ids), self.user.oauth_access_max_token + ) + + def test_remove_oauth_access_token(self): + res = self.user._get_session_token_fields() + self.assertFalse("oauth_access_token" in res) + self.assertTrue("oauth_master_uuid" in res) + + def test_action_oauth_clear_token(self): + self.user.action_oauth_clear_token() + active_token = self.user.oauth_access_token_ids + self.assertEqual(len(active_token), 0) diff --git a/auth_oauth_multi_token/views/auth_oauth_multi_token.xml b/auth_oauth_multi_token/views/auth_oauth_multi_token.xml new file mode 100644 index 0000000000..7c67b8ea2b --- /dev/null +++ b/auth_oauth_multi_token/views/auth_oauth_multi_token.xml @@ -0,0 +1,19 @@ + + + + auth_oauth_multi_token form + auth.oauth.multi.token + form + +
+ + + + + + + +
+
+
+
diff --git a/auth_oauth_multi_token/views/res_users.xml b/auth_oauth_multi_token/views/res_users.xml new file mode 100644 index 0000000000..4fb146d97c --- /dev/null +++ b/auth_oauth_multi_token/views/res_users.xml @@ -0,0 +1,34 @@ + + + + auth_oauth_multi_token user form + res.users + form + + + + + + + +