From 18f16fa193c0fbe8dc82f0ae4790bfed0fe8ba0b Mon Sep 17 00:00:00 2001 From: Michiel Holtkamp Date: Mon, 3 Feb 2020 19:28:15 +0100 Subject: [PATCH] Bugfix for default name_id_policy (#57) Bugfix for default name_id_policy --- djangosaml2idp/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/djangosaml2idp/views.py b/djangosaml2idp/views.py index f90b73c..17db789 100644 --- a/djangosaml2idp/views.py +++ b/djangosaml2idp/views.py @@ -157,7 +157,12 @@ def get_authn(self, req_info=None): def build_authn_response(self, user, authn, resp_args, processor: BaseProcessor, sp_config: dict): """ pysaml2 server.Server.create_authn_response wrapper """ - sp_config['name_id_format'] = resp_args.get('name_id_policy').format or NAMEID_FORMAT_UNSPECIFIED + policy = resp_args.get('name_id_policy', None) + if policy is None: + sp_config['name_id_format'] = NAMEID_FORMAT_UNSPECIFIED + else: + sp_config['name_id_format'] = policy.format + idp_name_id_format_list = self.IDP.config.getattr("name_id_format", "idp") or [NAMEID_FORMAT_UNSPECIFIED] if sp_config['name_id_format'] not in idp_name_id_format_list: