Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth saml unsolicited request #615

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions auth_saml/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
res_config_settings,
res_users,
res_users_saml,
res_company,
)
12 changes: 11 additions & 1 deletion auth_saml/models/auth_saml_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ class AuthSamlProvider(models.Model):
help="Whether metadata should be signed or not",
)

allow_saml_unsolicited_req = fields.Boolean(
compute="_compute_allow_saml_unsolicited"
)

@api.model
def _sig_alg_selection(self):
return [(sig[0], sig[0]) for sig in ds.SIG_ALLOWED_ALG]
Expand Down Expand Up @@ -219,7 +223,7 @@ def _get_config_for_provider(self, base_url: str = None) -> Saml2Config:
(acs_url, saml2.BINDING_HTTP_POST),
],
},
"allow_unsolicited": False,
"allow_unsolicited": self.allow_saml_unsolicited_req,
"authn_requests_signed": self.authn_requests_signed,
"logout_requests_signed": self.logout_requests_signed,
"want_assertions_signed": self.want_assertions_signed,
Expand Down Expand Up @@ -370,3 +374,9 @@ def _hook_validate_auth_response(self, response, matching_value):
vals[attribute.field_name] = attribute_value

return {"mapped_attrs": vals}

def _compute_allow_saml_unsolicited(self):
self.ensure_one()
self.allow_saml_unsolicited_req = self.env.company.allow_saml_unsolicited_req


1 change: 0 additions & 1 deletion auth_saml/models/ir_config_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
_logger = logging.getLogger(__name__)
ALLOW_SAML_UID_AND_PASSWORD = "auth_saml.allow_saml_uid_and_internal_password"


class IrConfigParameter(models.Model):
"""Redefined to update users when our parameter is changed."""

Expand Down
8 changes: 8 additions & 0 deletions auth_saml/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-

from odoo import models, api, fields, _

class ResCompany(models.Model):
_inherit = 'res.company'

allow_saml_unsolicited_req = fields.Boolean()
5 changes: 5 additions & 0 deletions auth_saml/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ class ResConfigSettings(models.TransientModel):
"Allow SAML users to possess an Odoo password (warning: decreases security)",
config_parameter=ALLOW_SAML_UID_AND_PASSWORD,
)

allow_saml_unsolicited_req = fields.Boolean(
related='company_id.allow_saml_unsolicited_req', readonly=False
)

6 changes: 6 additions & 0 deletions auth_saml/views/res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<div class="o_setting_right_pane">
<label for="allow_saml_uid_and_internal_password" />
</div>
<div class="o_setting_left_pane">
<field name="allow_saml_unsolicited_req" />
</div>
<div class="o_setting_right_pane">
<label for="allow_saml_unsolicited_req" />
</div>
</div>
</xpath>
</field>
Expand Down
Loading