diff --git a/auth_saml_create_user/README.rst b/auth_saml_create_user/README.rst new file mode 100644 index 0000000000..e9a0dcf31e --- /dev/null +++ b/auth_saml_create_user/README.rst @@ -0,0 +1,105 @@ +===================== +Auth SAML Create User +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:56b50e53c8da439f4b9ffe0ba3860c479fa5ca82e655b4c46da70b16ad0e131d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_saml_create_user + :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_saml_create_user + :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 extends the functionality of Auth SAML to support the automatic creation of +SAML users when they don't exist in odoo. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Check to true the create user option in the SAML Provider configuration + +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 +~~~~~~~ + +* Savoir-faire Linux + +Contributors +~~~~~~~~~~~~ + +* Luis Garcia(luis.garcia@savoirfairelinux.com) +* Jerome Oufella(jerome.oufella@savoirfairelinux.com) +* Rim Ben Dhaou +* Larbi Gharib +* Pierre Gault +* William Beverly + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Savoir-faire Linux +* Odoo Community Association (OCA) + +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-eilst| image:: https://github.com/eilst.png?size=40px + :target: https://github.com/eilst + :alt: eilst + +Current `maintainer `__: + +|maintainer-eilst| + +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_saml_create_user/__init__.py b/auth_saml_create_user/__init__.py new file mode 100644 index 0000000000..2041038ef5 --- /dev/null +++ b/auth_saml_create_user/__init__.py @@ -0,0 +1,4 @@ +# © 2019 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/auth_saml_create_user/__manifest__.py b/auth_saml_create_user/__manifest__.py new file mode 100644 index 0000000000..db5b8dfa4f --- /dev/null +++ b/auth_saml_create_user/__manifest__.py @@ -0,0 +1,21 @@ +# © 2019 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Auth SAML Create User", + "summary": """ + This module extends the functionality of Auth SAML to support + the automatic creation of SAML users when they don't exist in odoo.""", + "author": "Savoir-faire Linux, Odoo Community Association (OCA)", + "maintainers": ["eilst"], + "website": "https://github.com/OCA/server-auth", + "license": "AGPL-3", + "category": "Tools", + "version": "16.0.1.0.0", + "depends": ["auth_saml"], + "data": [ + # "data/auth_saml_create_user.xml", + "views/auth_saml.xml", + ], + "development_status": "Beta", +} diff --git a/auth_saml_create_user/data/auth_saml_create_user.xml b/auth_saml_create_user/data/auth_saml_create_user.xml new file mode 100644 index 0000000000..3d92335961 --- /dev/null +++ b/auth_saml_create_user/data/auth_saml_create_user.xml @@ -0,0 +1,125 @@ + + + + Local Authentic server + True + + + + + + + MIIDXTCCAkWgAwIBAgIJALmVVuDWu4NYMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwHhcNMTYxMjMxMTQzNDQ3WhcNNDgwNjI1MTQzNDQ3WjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzUCFozgNb1h1M0jzNRSCjhOBnR+uVbVpaWfXYIR+AhWDdEe5ryY+CgavOg8bfLybyzFdehlYdDRgkedEB/GjG8aJw06l0qF4jDOAw0kEygWCu2mcH7XOxRt+YAH3TVHa/Hu1W3WjzkobqqqLQ8gkKWWM27fOgAZ6GieaJBN6VBSMMcPey3HWLBmc+TYJmv1dbaO2jHhKh8pfKw0W12VM8P1PIO8gv4Phu/uuJYieBWKixBEyy0lHjyixYFCR12xdh4CA47q958ZRGnnDUGFVE1QhgRacJCOZ9bd5t9mr8KLaVBYTCJo5ERE8jymab5dPqe5qKfJsCZiqWglbjUo9twIDAQABo1AwTjAdBgNVHQ4EFgQUxpuwcs/CYQOyui+r1G+3KxBNhxkwHwYDVR0jBBgwFoAUxpuwcs/CYQOyui+r1G+3KxBNhxkwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAAiWUKs/2x/viNCKi3Y6blEuCtAGhz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jBBgwFoAUxpuwcs/CYQOyui+r1G+3KxBNhxkwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAAiWUKs/2x/viNCKi3Y6blEuCtAGhzOOZ9EjrvJ8+COH3Rag3tVBWrcBZ3/uhhPq5gy9lqw4OkvEws99/5jFsX1FJ6MKBgqfuy7yh5s1YfM0ANHYczMmYpZeAcQf2CGAaVfwTTfSlzNLsF2lW/ly7yapFzlYSJLGoVE+OHEu8g5SlNACUEfkXw+5Eghh+KzlIN7R6Q7r2ixWNFBC/jWf7NKUfJyX8qIG5md1YUeT6GBW9Bm2/1/RiO24JTaYlfLdKK9TYb8sG5B+OLab2DImG99CJ25RkAcSobWNF5zD0O6lgOo3cEdB/ksCq3hmtlC/DlLZ/D8CJ+7VuZnS1rR2naQ== + + + + + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + zocial saml + Log in with Authentic + + SIG_RSA_SHA256 + + email + + diff --git a/auth_saml_create_user/i18n/auth_saml_create_user.pot b/auth_saml_create_user/i18n/auth_saml_create_user.pot new file mode 100644 index 0000000000..32d9ac1f69 --- /dev/null +++ b/auth_saml_create_user/i18n/auth_saml_create_user.pot @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_saml_create_user +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.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_saml_create_user +#: model:ir.model.fields,field_description:auth_saml_create_user.field_auth_saml_provider_create_user +msgid "Create User" +msgstr "" + +#. module: auth_saml_create_user +#: model:ir.model,name:auth_saml_create_user.model_auth_saml_provider +msgid "SAML2 provider" +msgstr "" + +#. module: auth_saml_create_user +#: model:ir.model,name:auth_saml_create_user.model_res_users +msgid "Users" +msgstr "" + diff --git a/auth_saml_create_user/models/__init__.py b/auth_saml_create_user/models/__init__.py new file mode 100644 index 0000000000..51103236b6 --- /dev/null +++ b/auth_saml_create_user/models/__init__.py @@ -0,0 +1,5 @@ +# © 2018 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import auth_saml +from . import res_users diff --git a/auth_saml_create_user/models/auth_saml.py b/auth_saml_create_user/models/auth_saml.py new file mode 100644 index 0000000000..1a409ce476 --- /dev/null +++ b/auth_saml_create_user/models/auth_saml.py @@ -0,0 +1,12 @@ +# Copyright (C) 2010-2016 XCG Consulting +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AuthSamlProvider(models.Model): + _inherit = "auth.saml.provider" + + create_user = fields.Boolean( + string="Create User", + ) diff --git a/auth_saml_create_user/models/res_users.py b/auth_saml_create_user/models/res_users.py new file mode 100644 index 0000000000..d8acbcb205 --- /dev/null +++ b/auth_saml_create_user/models/res_users.py @@ -0,0 +1,52 @@ +# © 2019 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging +import random + +from odoo import models + +_logger = logging.getLogger(__name__) +s = "abcdefghijklmnopqrstuvwxyz034567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?" +passlen = 16 + + +class ResUsers(models.Model): + _inherit = "res.users" + + def _auth_saml_signin(self, provider: int, validation: dict, saml_response) -> str: + saml_uid = validation["user_id"] + user_ids = self.env["res.users.saml"].search( + [("saml_uid", "=", saml_uid), ("saml_provider_id", "=", provider)] + ) + if self.check_if_create_user(provider) and not user_ids: + self.create_user(saml_uid, provider) + return super()._auth_saml_signin(provider, validation, saml_response) + + def check_if_create_user(self, provider): + return self.env["auth.saml.provider"].browse(provider).create_user + + def create_user(self, saml_uid, provider): + _logger.debug('Creating new Odoo user "%s" from SAML' % saml_uid) + SudoUser = self.env["res.users"].sudo() + new_user = SudoUser.create( + { + "name": saml_uid, + "login": saml_uid, + "password": "".join(random.sample(s, passlen)), + "company_id": self.env["res.company"].sudo().browse(1).id, + } + ) + vals = { + "saml_provider_id": provider, + "saml_uid": saml_uid, + "user_id": new_user.id, + } + self.env["res.users.saml"].create(vals) + + # Note: we need to commit to database because otherwise in phase of the first login + # the user obtain: "You do not have access to this database. Please contact support." + # However the account was created successfully + self.env.cr.commit() + + return new_user diff --git a/auth_saml_create_user/readme/CONTRIBUTORS.rst b/auth_saml_create_user/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..c9d627a072 --- /dev/null +++ b/auth_saml_create_user/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* Luis Garcia(luis.garcia@savoirfairelinux.com) +* Jerome Oufella(jerome.oufella@savoirfairelinux.com) +* Rim Ben Dhaou +* Larbi Gharib +* Pierre Gault +* William Beverly diff --git a/auth_saml_create_user/readme/CREDITS.rst b/auth_saml_create_user/readme/CREDITS.rst new file mode 100644 index 0000000000..4eec2ce80c --- /dev/null +++ b/auth_saml_create_user/readme/CREDITS.rst @@ -0,0 +1,4 @@ +The development of this module has been financially supported by: + +* Savoir-faire Linux +* Odoo Community Association (OCA) diff --git a/auth_saml_create_user/readme/DESCRIPTION.rst b/auth_saml_create_user/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..564528b8df --- /dev/null +++ b/auth_saml_create_user/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module extends the functionality of Auth SAML to support the automatic creation of +SAML users when they don't exist in odoo. diff --git a/auth_saml_create_user/readme/USAGE.rst b/auth_saml_create_user/readme/USAGE.rst new file mode 100644 index 0000000000..e568bc2e8c --- /dev/null +++ b/auth_saml_create_user/readme/USAGE.rst @@ -0,0 +1,3 @@ +To use this module, you need to: + +#. Check to true the create user option in the SAML Provider configuration diff --git a/auth_saml_create_user/static/description/icon.png b/auth_saml_create_user/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/auth_saml_create_user/static/description/icon.png differ diff --git a/auth_saml_create_user/static/description/index.html b/auth_saml_create_user/static/description/index.html new file mode 100644 index 0000000000..f68edf188e --- /dev/null +++ b/auth_saml_create_user/static/description/index.html @@ -0,0 +1,448 @@ + + + + + +Auth SAML Create User + + + +
+

Auth SAML Create User

+ + +

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

+

This module extends the functionality of Auth SAML to support the automatic creation of +SAML users when they don’t exist in odoo.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Check to true the create user option in the SAML Provider configuration
  2. +
+
+
+

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

+
    +
  • Savoir-faire Linux
  • +
+
+ +
+

Other credits

+

The development of this module has been financially supported by:

+
    +
  • Savoir-faire Linux
  • +
  • Odoo Community Association (OCA)
  • +
+
+
+

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:

+

eilst

+

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_saml_create_user/tests/__init__.py b/auth_saml_create_user/tests/__init__.py new file mode 100644 index 0000000000..2c8a1456b0 --- /dev/null +++ b/auth_saml_create_user/tests/__init__.py @@ -0,0 +1,5 @@ +# © 2019 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import common +from . import test_auth_saml_create_users diff --git a/auth_saml_create_user/tests/arguments.py b/auth_saml_create_user/tests/arguments.py new file mode 100644 index 0000000000..71d2a7982d --- /dev/null +++ b/auth_saml_create_user/tests/arguments.py @@ -0,0 +1,138 @@ +provider = 2 +validation = {"user_id": "user2@example.com"}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Y\ + Wx1ZT48L3NhbWw6QXR0cmlidXRlPjxzYW1sOkF0dHJpYnV0ZSBOYW1lPSJlbWFpbCIgTmF\ + tZUZvcm1hdD0idXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOmF0dHJuYW1lLWZvcm1hd\ + DpiYXNpYyI+PHNhbWw6QXR0cmlidXRlVmFsdWUgeHNpOnR5cGU9InhzOnN0cmluZyI+dXN\ + lcjJAZXhhbXBsZS5jb208L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0Z\ + T48L3NhbWw6QXR0cmlidXRlU3RhdGVtZW50Pjwvc2FtbDpBc3NlcnRpb24+PC9zYW1scDp\ + SZXNwb25zZT4=" diff --git a/auth_saml_create_user/tests/common.py b/auth_saml_create_user/tests/common.py new file mode 100644 index 0000000000..1b24810f5a --- /dev/null +++ b/auth_saml_create_user/tests/common.py @@ -0,0 +1,18 @@ +# © 2019 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import common + + +class TestAuthSamlCreateUserCommon(common.TransactionCase): + def setUp(self): + super(TestAuthSamlCreateUserCommon, self).setUp() + self.env.ref("auth_saml.allow_saml_uid_and_internal_password").write( + {"value": 1} + ) + + # Usefull models + self.SamlProvider = self.env["auth.saml.provider"] + self.ResUsers = self.env["res.users"] + + self.provider = self.env.ref("auth_saml_create_user.provider_local_create_user") diff --git a/auth_saml_create_user/tests/test_auth_saml_create_users.py b/auth_saml_create_user/tests/test_auth_saml_create_users.py new file mode 100644 index 0000000000..b53b10b438 --- /dev/null +++ b/auth_saml_create_user/tests/test_auth_saml_create_users.py @@ -0,0 +1,27 @@ +# © 2019 Savoir-faire Linux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from .arguments import provider, saml_response, validation +from .common import TestAuthSamlCreateUserCommon + + +class TestAuthSamlCreateUser(TestAuthSamlCreateUserCommon): + def setUp(self): + super(TestAuthSamlCreateUser, self).setUp() + + def test_010_auth_saml_signin(self): + self.ResUsers._auth_saml_signin(provider, validation, saml_response) + + def test_020_check_if_should_create_user(self): + self.assertEqual( + self.provider.create_user, + self.ResUsers.check_if_create_user(self.provider.id), + ) + + def test_030_create_user(self): + saml_uid = "new_test_user12312az@test.com" + user_ids = self.ResUsers.search([("saml_uid", "=", saml_uid)]) + self.assertTrue(not user_ids) + self.ResUsers.create_user(saml_uid, provider) + user_ids = self.ResUsers.search([("saml_uid", "=", saml_uid)]) + self.assertTrue(user_ids) diff --git a/auth_saml_create_user/views/auth_saml.xml b/auth_saml_create_user/views/auth_saml.xml new file mode 100644 index 0000000000..176cb512da --- /dev/null +++ b/auth_saml_create_user/views/auth_saml.xml @@ -0,0 +1,19 @@ + + + + auth.saml.provider.form.inherit + auth.saml.provider + + + + + + + diff --git a/setup/auth_saml_create_user/odoo/addons/auth_saml_create_user b/setup/auth_saml_create_user/odoo/addons/auth_saml_create_user new file mode 120000 index 0000000000..9d8265e639 --- /dev/null +++ b/setup/auth_saml_create_user/odoo/addons/auth_saml_create_user @@ -0,0 +1 @@ +../../../../auth_saml_create_user \ No newline at end of file diff --git a/setup/auth_saml_create_user/setup.cfg b/setup/auth_saml_create_user/setup.cfg new file mode 100644 index 0000000000..3c6e79cf31 --- /dev/null +++ b/setup/auth_saml_create_user/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/setup/auth_saml_create_user/setup.py b/setup/auth_saml_create_user/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/auth_saml_create_user/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)