diff --git a/auth_saml_environment/README.rst b/auth_saml_environment/README.rst new file mode 100644 index 000000000..8257f0c1f --- /dev/null +++ b/auth_saml_environment/README.rst @@ -0,0 +1,115 @@ +====================== +Auth SAML environement +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:796938aa29409152ab5821f0ea98ef74f1b7a6e9a2ee2661fa51fb2d8f71b648 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--env-lightgray.png?logo=github + :target: https://github.com/OCA/server-env/tree/18.0/auth_saml_environment + :alt: OCA/server-env +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-env-18-0/server-env-18-0-auth_saml_environment + :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-env&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to use server env for SAML configuration + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +To install this module, you need to have the following modules installed +and properly configured: server_environment module auth_saml + +Configuration +============= + +To configure this module, you need to: + +Create a module server_environment_file with a cfg file or set the +environment variable SERVER_ENV_CONFIG with the following section: + +[auth_saml_provider.] + +Where is optional and must be equal to the name field you defined +in Odoo for the IDP. + +Example of configuration + +[auth_saml_provider.my_idp] + +idp_metadata=<...> sp_baseurl=\ https://odoo-community.org +sp_pem_public_path=/data/cert.pem sp_pem_private_path=/data/key.pem + +Usage +===== + +Once configured, Odoo will read the Auth SAML Providers values from the +configuration. + +Known issues / Roadmap +====================== + +- Due to the special nature of this addon, you cannot test it on the OCA + runbot. + +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 +------------ + +- Denis Leemann +- Yannick Vaucher + +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-env `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/auth_saml_environment/__init__.py b/auth_saml_environment/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/auth_saml_environment/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/auth_saml_environment/__manifest__.py b/auth_saml_environment/__manifest__.py new file mode 100644 index 000000000..7988b368d --- /dev/null +++ b/auth_saml_environment/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2021 Camptocamp SA (http://www.camptocamp.ch) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + "name": "Auth SAML environement", + "summary": "Allows system administrator to authenticate with any account", + "version": "18.0.1.0.0", + "category": "base", + "author": "Camptocamp,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-env", + "license": "AGPL-3", + "depends": [ + "auth_saml", + "server_environment", + ], + "data": [ + "views/saml_provider_view.xml", + ], + "installable": True, +} diff --git a/auth_saml_environment/i18n/auth_saml_environment.pot b/auth_saml_environment/i18n/auth_saml_environment.pot new file mode 100644 index 000000000..af3e5a575 --- /dev/null +++ b/auth_saml_environment/i18n/auth_saml_environment.pot @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_saml_environment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: auth_saml_environment +#: model:ir.model.fields,help:auth_saml_environment.field_auth_saml_provider__idp_metadata +msgid "" +"Configuration for this Identity Provider. Supplied by the provider, in XML " +"format." +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__display_name +msgid "Display Name" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__id +msgid "ID" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__idp_metadata +msgid "Identity Provider Metadata" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider____last_update +msgid "Last Modified on" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model,name:auth_saml_environment.model_auth_saml_provider +msgid "SAML2 Provider" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__server_env_defaults +msgid "Server Env Defaults" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_private +msgid "Sp Pem Private" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_public +msgid "Sp Pem Public" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_private_path +msgid "sp_pem_private_path env config value" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_public_path +msgid "sp_pem_public_path env config value" +msgstr "" diff --git a/auth_saml_environment/i18n/ca.po b/auth_saml_environment/i18n/ca.po new file mode 100644 index 000000000..bca997600 --- /dev/null +++ b/auth_saml_environment/i18n/ca.po @@ -0,0 +1,72 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_saml_environment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ca\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" + +#. module: auth_saml_environment +#: model:ir.model.fields,help:auth_saml_environment.field_auth_saml_provider__idp_metadata +msgid "" +"Configuration for this Identity Provider. Supplied by the provider, in XML " +"format." +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__display_name +msgid "Display Name" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__id +msgid "ID" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__idp_metadata +msgid "Identity Provider Metadata" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider____last_update +msgid "Last Modified on" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model,name:auth_saml_environment.model_auth_saml_provider +msgid "SAML2 Provider" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__server_env_defaults +msgid "Server Env Defaults" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_private +msgid "Sp Pem Private" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_public +msgid "Sp Pem Public" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_private_path +msgid "sp_pem_private_path env config value" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_public_path +msgid "sp_pem_public_path env config value" +msgstr "" diff --git a/auth_saml_environment/i18n/it.po b/auth_saml_environment/i18n/it.po new file mode 100644 index 000000000..9ec437476 --- /dev/null +++ b/auth_saml_environment/i18n/it.po @@ -0,0 +1,74 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * auth_saml_environment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-03-14 15:06+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 5.10.2\n" + +#. module: auth_saml_environment +#: model:ir.model.fields,help:auth_saml_environment.field_auth_saml_provider__idp_metadata +msgid "" +"Configuration for this Identity Provider. Supplied by the provider, in XML " +"format." +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__id +msgid "ID" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__idp_metadata +msgid "Identity Provider Metadata" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider____last_update +msgid "Last Modified on" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model,name:auth_saml_environment.model_auth_saml_provider +msgid "SAML2 Provider" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__server_env_defaults +msgid "Server Env Defaults" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_private +msgid "Sp Pem Private" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_public +msgid "Sp Pem Public" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_private_path +msgid "sp_pem_private_path env config value" +msgstr "" + +#. module: auth_saml_environment +#: model:ir.model.fields,field_description:auth_saml_environment.field_auth_saml_provider__sp_pem_public_path +msgid "sp_pem_public_path env config value" +msgstr "" diff --git a/auth_saml_environment/models/__init__.py b/auth_saml_environment/models/__init__.py new file mode 100644 index 000000000..d7324d453 --- /dev/null +++ b/auth_saml_environment/models/__init__.py @@ -0,0 +1 @@ +from . import auth_saml_provider diff --git a/auth_saml_environment/models/auth_saml_provider.py b/auth_saml_environment/models/auth_saml_provider.py new file mode 100644 index 000000000..ed8c1bc7e --- /dev/null +++ b/auth_saml_environment/models/auth_saml_provider.py @@ -0,0 +1,51 @@ +# Copyright 2021 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo import api, fields, models + + +class AuthSamlProvider(models.Model): + _name = "auth.saml.provider" + _inherit = ["auth.saml.provider", "server.env.mixin"] + + # Non-mandatory to be able to create objects + idp_metadata = fields.Text(required=False) + sp_pem_public = fields.Char(required=False) + sp_pem_private = fields.Char(required=False) + entity_id = fields.Char(required=False) + + sp_pem_public_path = fields.Char( + string="sp_pem_public_path env config value", + ) + + sp_pem_private_path = fields.Char( + string="sp_pem_private_path env config value", + ) + + @property + def _server_env_fields(self): + base_fields = super()._server_env_fields + auth_saml_fields = { + "idp_metadata": {}, + "sp_baseurl": {}, + "sp_pem_public_path": {}, + "sp_pem_private_path": {}, + "entity_id": {}, + } + auth_saml_fields.update(base_fields) + return auth_saml_fields + + @api.model + def _server_env_global_section_name(self): + """Name of the global section in the configuration files + Can be customized in your model + """ + return "auth_saml_provider" + + def _get_cert_key_path(self, field="sp_pem_public"): + # If the setup is done in env, we want to bypass the base method + if self.sp_pem_public_path and field == "sp_pem_public": + return self.sp_pem_public_path + if self.sp_pem_private_path and field == "sp_pem_private": + return self.sp_pem_private_path + return super()._get_cert_key_path(field) diff --git a/auth_saml_environment/pyproject.toml b/auth_saml_environment/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/auth_saml_environment/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/auth_saml_environment/readme/CONFIGURE.md b/auth_saml_environment/readme/CONFIGURE.md new file mode 100644 index 000000000..18f37a953 --- /dev/null +++ b/auth_saml_environment/readme/CONFIGURE.md @@ -0,0 +1,16 @@ +To configure this module, you need to: + +Create a module server_environment_file with a cfg file or set the +environment variable SERVER_ENV_CONFIG with the following section: + +\[auth_saml_provider.\\] + +Where \ is optional and must be equal to the name field you +defined in Odoo for the IDP. + +Example of configuration + +\[auth_saml_provider.my_idp\] + +idp_metadata=\<...\> sp_baseurl=https://odoo-community.org +sp_pem_public_path=/data/cert.pem sp_pem_private_path=/data/key.pem diff --git a/auth_saml_environment/readme/CONTRIBUTORS.md b/auth_saml_environment/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..de088a14d --- /dev/null +++ b/auth_saml_environment/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Denis Leemann \ +- Yannick Vaucher \ diff --git a/auth_saml_environment/readme/DESCRIPTION.md b/auth_saml_environment/readme/DESCRIPTION.md new file mode 100644 index 000000000..8c7db203f --- /dev/null +++ b/auth_saml_environment/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allows to use server env for SAML configuration diff --git a/auth_saml_environment/readme/INSTALL.md b/auth_saml_environment/readme/INSTALL.md new file mode 100644 index 000000000..e2791cea1 --- /dev/null +++ b/auth_saml_environment/readme/INSTALL.md @@ -0,0 +1,2 @@ +To install this module, you need to have the following modules installed +and properly configured: server_environment module auth_saml diff --git a/auth_saml_environment/readme/ROADMAP.md b/auth_saml_environment/readme/ROADMAP.md new file mode 100644 index 000000000..9d5b75d69 --- /dev/null +++ b/auth_saml_environment/readme/ROADMAP.md @@ -0,0 +1,2 @@ +- Due to the special nature of this addon, you cannot test it on the OCA + runbot. diff --git a/auth_saml_environment/readme/USAGE.md b/auth_saml_environment/readme/USAGE.md new file mode 100644 index 000000000..f9450f8ff --- /dev/null +++ b/auth_saml_environment/readme/USAGE.md @@ -0,0 +1,2 @@ +Once configured, Odoo will read the Auth SAML Providers values from the +configuration. diff --git a/auth_saml_environment/static/description/icon.png b/auth_saml_environment/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/auth_saml_environment/static/description/icon.png differ diff --git a/auth_saml_environment/static/description/index.html b/auth_saml_environment/static/description/index.html new file mode 100644 index 000000000..500793bd2 --- /dev/null +++ b/auth_saml_environment/static/description/index.html @@ -0,0 +1,458 @@ + + + + + +Auth SAML environement + + + +
+

Auth SAML environement

+ + +

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

+

This module allows to use server env for SAML configuration

+

Table of contents

+ +
+

Installation

+

To install this module, you need to have the following modules installed +and properly configured: server_environment module auth_saml

+
+
+

Configuration

+

To configure this module, you need to:

+

Create a module server_environment_file with a cfg file or set the +environment variable SERVER_ENV_CONFIG with the following section:

+

[auth_saml_provider.<name>]

+

Where <name> is optional and must be equal to the name field you defined +in Odoo for the IDP.

+

Example of configuration

+

[auth_saml_provider.my_idp]

+

idp_metadata=<…> sp_baseurl=https://odoo-community.org +sp_pem_public_path=/data/cert.pem sp_pem_private_path=/data/key.pem

+
+
+

Usage

+

Once configured, Odoo will read the Auth SAML Providers values from the +configuration.

+
+
+

Known issues / Roadmap

+
    +
  • Due to the special nature of this addon, you cannot test it on the OCA +runbot.
  • +
+
+
+

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
  • +
+
+ +
+

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

+

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

+
+
+
+ + diff --git a/auth_saml_environment/tests/__init__.py b/auth_saml_environment/tests/__init__.py new file mode 100644 index 000000000..120bcdfee --- /dev/null +++ b/auth_saml_environment/tests/__init__.py @@ -0,0 +1 @@ +from . import test_environment_variable diff --git a/auth_saml_environment/tests/test_environment_variable.py b/auth_saml_environment/tests/test_environment_variable.py new file mode 100644 index 000000000..ac3bcd560 --- /dev/null +++ b/auth_saml_environment/tests/test_environment_variable.py @@ -0,0 +1,37 @@ +# Copyright 2021 Camptocamp (https://www.camptocamp.com). +# License GPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from unittest.mock import patch + +from odoo.tools.config import config as odoo_config + +from odoo.addons.server_environment import server_env +from odoo.addons.server_environment.tests.common import ServerEnvironmentCase + + +@patch.dict(odoo_config.options, {"running_env": "testing"}) +class TestEnvironmentVariables(ServerEnvironmentCase): + def test_env_variables(self): + env_var = ( + "[auth_saml_provider.sample]\n" + "idp_metadata=foo\n" + "sp_baseurl=bar\n" + "sp_pem_public_path=file1.txt\n" + "sp_pem_private_path=file2.txt\n" + "entity_id=myentity" + ) + with self.set_config_dir(None), self.set_env_variables(env_var): + parser = server_env._load_config() + self.assertEqual( + list(parser.keys()), ["DEFAULT", "auth_saml_provider.sample"] + ) + self.assertDictEqual( + dict(parser["auth_saml_provider.sample"].items()), + { + "idp_metadata": "foo", + "sp_baseurl": "bar", + "sp_pem_public_path": "file1.txt", + "sp_pem_private_path": "file2.txt", + "entity_id": "myentity", + }, + ) diff --git a/auth_saml_environment/views/saml_provider_view.xml b/auth_saml_environment/views/saml_provider_view.xml new file mode 100644 index 000000000..7710c1b6e --- /dev/null +++ b/auth_saml_environment/views/saml_provider_view.xml @@ -0,0 +1,23 @@ + + + + auth.saml.provider.form + auth.saml.provider + + + + + + + + + + + 1 + + + 1 + + + +