Skip to content

Commit 2aedfa0

Browse files
committed
make both sign response and assertion configurable but with saml2int as a baseline for default settings
1 parent f0c3ea6 commit 2aedfa0

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/satosa/frontends/saml2.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import logging
88
from urllib.parse import urlparse
9+
from distutils.util import strtobool
910

1011
from saml2 import SAMLError, xmldsig
1112
from saml2.config import IdPConfig
@@ -287,13 +288,28 @@ def _handle_authn_response(self, context, internal_response, idp):
287288

288289
satosa_logging(logger, logging.DEBUG, "returning attributes %s" % json.dumps(ava), context.state)
289290

291+
# assume saml2int defaults: sign response but not the assertion & allow override
292+
sign_assertion = False
293+
try:
294+
sign_assertion = strtobool(self.config['idp_config']['service']['idp']['policy']['default']['sign_assertion'])
295+
sign_assertion = strtobool(self.config['idp_config']['service']['idp']['policy'][resp_args['sp_entity_id']]['sign_assertion'])
296+
except (KeyError, AttributeError, ValueError):
297+
pass
298+
299+
sign_response = True
300+
try:
301+
sign_response = strtobool(self.config['idp_config']['service']['idp']['policy']['default']['sign_response'])
302+
sign_response = strtobool(self.config['idp_config']['service']['idp']['policy'][resp_args['sp_entity_id']]['sign_response'])
303+
except (KeyError, AttributeError, ValueError):
304+
pass
305+
290306
# Construct arguments for method create_authn_response on IdP Server instance
291307
args = {
292308
'identity' : ava,
293309
'name_id' : name_id,
294310
'authn' : auth_info,
295-
'sign_response' : True,
296-
'sign_assertion': True
311+
'sign_response' : sign_response,
312+
'sign_assertion': sign_assertion
297313
}
298314

299315
# Add the SP details

0 commit comments

Comments
 (0)