diff --git a/README.md b/README.md index c54dbb121f..421d94f130 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ addon | version | maintainers | summary [auth_ldaps](auth_ldaps/) | 15.0.1.0.0 | | Allows to use LDAP over SSL authentication [auth_oauth_multi_token](auth_oauth_multi_token/) | 15.0.1.0.1 | | Allow multiple connection with the same OAuth account [auth_oidc](auth_oidc/) | 15.0.1.1.0 | [![sbidoul](https://github.com/sbidoul.png?size=30px)](https://github.com/sbidoul) | Allow users to login through OpenID Connect Provider -[auth_saml](auth_saml/) | 15.0.1.4.2 | [![vincent-hatakeyama](https://github.com/vincent-hatakeyama.png?size=30px)](https://github.com/vincent-hatakeyama) | SAML2 Authentication +[auth_saml](auth_saml/) | 15.0.1.4.3 | [![vincent-hatakeyama](https://github.com/vincent-hatakeyama.png?size=30px)](https://github.com/vincent-hatakeyama) | SAML2 Authentication [auth_session_timeout](auth_session_timeout/) | 15.0.1.0.0 | | This module disable all inactive sessions since a given delay [auth_signup_partner_company](auth_signup_partner_company/) | 15.0.1.0.0 | | Auth Signup Partner Company [auth_signup_verify_email](auth_signup_verify_email/) | 15.0.1.0.0 | | Force uninvited users to use a good email for signup diff --git a/auth_saml/README.rst b/auth_saml/README.rst index 0522b0da33..1dcf66b922 100644 --- a/auth_saml/README.rst +++ b/auth_saml/README.rst @@ -7,7 +7,7 @@ SAML2 Authentication !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:749f38cb523fb18981d9e229196105be0adc619147af5f55e3c887b25ca86dc0 + !! source digest: sha256:139e220611ae66b5caca3b9586fb543ebc5de97db011e239ec48e389950beba5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/auth_saml/__manifest__.py b/auth_saml/__manifest__.py index 84bc2fcc11..9df29573b9 100644 --- a/auth_saml/__manifest__.py +++ b/auth_saml/__manifest__.py @@ -4,7 +4,7 @@ { "name": "SAML2 Authentication", - "version": "15.0.1.4.2", + "version": "15.0.1.4.3", "category": "Tools", "author": "XCG Consulting, Odoo Community Association (OCA)", "maintainers": ["vincent-hatakeyama"], diff --git a/auth_saml/models/ir_config_parameter.py b/auth_saml/models/ir_config_parameter.py index 9fb503afac..dd8677d0fa 100644 --- a/auth_saml/models/ir_config_parameter.py +++ b/auth_saml/models/ir_config_parameter.py @@ -27,3 +27,13 @@ def write(self, vals): if self.filtered(lambda param: param.key == ALLOW_SAML_UID_AND_PASSWORD): self.env["res.users"].allow_saml_and_password_changed() return result + + def unlink(self): + """Redefined to update users when our parameter is deleted.""" + param_saml = self.filtered( + lambda param: param.key == ALLOW_SAML_UID_AND_PASSWORD + ) + result = super().unlink() + if result and param_saml: + self.env["res.users"].allow_saml_and_password_changed() + return result diff --git a/auth_saml/tests/test_pysaml.py b/auth_saml/tests/test_pysaml.py index c05235b747..7549e2546f 100644 --- a/auth_saml/tests/test_pysaml.py +++ b/auth_saml/tests/test_pysaml.py @@ -198,7 +198,7 @@ def test_login_with_saml(self): # User should now be able to log in with the token self.authenticate(user="test@example.com", password=token) - def test_disallow_user_password_when_changing_setting(self): + def test_disallow_user_password_when_changing_ir_config_parameter(self): """Test that disabling users from having both a password and SAML ids remove users password.""" # change the option @@ -336,3 +336,26 @@ def test_redirect_after_login(self): self.base_url() + "/web#action=37&model=ir.module.module&view_type=kanban&menu_id=5", ) + + def test_disallow_user_password_when_changing_settings(self): + """Test that disabling the setting will remove passwords from related users""" + # We activate the settings to allow password login + self.env["res.config.settings"].create( + { + "allow_saml_uid_and_internal_password": True, + } + ).execute() + + # Test the user can login with the password + self.authenticate(user="user@example.com", password="NesTNSte9340D720te>/-A") + + self.env["res.config.settings"].create( + { + "allow_saml_uid_and_internal_password": False, + } + ).execute() + + with self.assertRaises(AccessDenied): + self.authenticate( + user="user@example.com", password="NesTNSte9340D720te>/-A" + )