Skip to content

Commit 0a83d58

Browse files
author
Roland Hedberg
committed
Some configuration parameters values should be True/False not "true"/"false".
1 parent e341cdc commit 0a83d58

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

doc/howto/config.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,13 @@ by default. This can be overriden by application code for a specific call.
351351
This sets the AuthnRequestsSigned attribute of the SPSSODescriptor node
352352
of the metadata so the IdP will know this SP preference.
353353

354-
Valid values are "true" or "false". Default value is "false".
354+
Valid values are True or False. Default value is True.
355355

356356
Example::
357357

358358
"service": {
359359
"sp": {
360-
"authn_requests_signed": "true",
360+
"authn_requests_signed": True,
361361
}
362362
}
363363

@@ -419,13 +419,13 @@ Indicates if this SP wants the IdP to send the assertions signed. This
419419
sets the WantAssertionsSigned attribute of the SPSSODescriptor node
420420
of the metadata so the IdP will know this SP preference.
421421

422-
Valid values are "true" or "false". Default value is "true".
422+
Valid values are True or False. Default value is True.
423423

424424
Example::
425425

426426
"service": {
427427
"sp": {
428-
"want_assertions_signed": "true",
428+
"want_assertions_signed": True,
429429
}
430430
}
431431

@@ -475,13 +475,13 @@ Indicates if this entity will sign the Logout Requests originated from it.
475475

476476
This can be overriden by application code for a specific call.
477477

478-
Valid values are "true" or "false". Default value is "false".
478+
Valid values are True or False. Default value is False.
479479

480480
Example::
481481

482482
"service": {
483483
"sp": {
484-
"logout_requests_signed": "true",
484+
"logout_requests_signed": False,
485485
}
486486
}
487487

src/saml2/config.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from saml2 import xmldsig
3636
from saml2 import xmlenc
3737

38-
3938
ONTS = {
4039
saml.NAMESPACE: saml,
4140
mdui.NAMESPACE: mdui,
@@ -49,7 +48,8 @@
4948
}
5049

5150
COMMON_ARGS = [
52-
"entityid", "xmlsec_binary", "debug", "key_file", "cert_file", "encryption_keypairs", "additional_cert_files",
51+
"entityid", "xmlsec_binary", "debug", "key_file", "cert_file",
52+
"encryption_keypairs", "additional_cert_files",
5353
"metadata_key_usage", "secret", "accepted_time_diff", "name", "ca_certs",
5454
"description", "valid_for", "verify_ssl_cert",
5555
"organization",
@@ -58,7 +58,6 @@
5858
"virtual_organization",
5959
"logger",
6060
"only_use_keys_in_metadata",
61-
"logout_requests_signed",
6261
"disable_ssl_certificate_validation",
6362
"referred_binding",
6463
"session_storage",
@@ -93,6 +92,7 @@
9392
"allow_unsolicited",
9493
"ecp",
9594
"name_id_format",
95+
"logout_requests_signed",
9696
]
9797

9898
AA_IDP_ARGS = [
@@ -176,6 +176,7 @@
176176
class ConfigurationError(SAMLError):
177177
pass
178178

179+
179180
# -----------------------------------------------------------------
180181

181182

@@ -254,9 +255,15 @@ def getattr(self, attr, context=None):
254255
def load_special(self, cnf, typ, metadata_construction=False):
255256
for arg in SPEC[typ]:
256257
try:
257-
self.setattr(typ, arg, cnf[arg])
258+
_val = cnf[arg]
258259
except KeyError:
259260
pass
261+
else:
262+
if _val == "true":
263+
_val = True
264+
elif _val == "false":
265+
_val = False
266+
self.setattr(typ, arg, _val)
260267

261268
self.context = typ
262269
self.load_complex(cnf, typ, metadata_construction=metadata_construction)
@@ -377,7 +384,7 @@ def load_file(self, config_file, metadata_construction=False):
377384
config_file = config_file[:-3]
378385

379386
mod = self._load(config_file)
380-
#return self.load(eval(open(config_file).read()))
387+
# return self.load(eval(open(config_file).read()))
381388
return self.load(copy.deepcopy(mod.CONFIG), metadata_construction)
382389

383390
def load_metadata(self, metadata_conf):

tests/test_31_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
"optional_attributes": ["title"],
6565
"idp": {
6666
"": "https://example.com/saml2/idp/SSOService.php",
67-
}
67+
},
68+
"authn_requests_signed": True,
69+
"logout_requests_signed": True,
6870
}
6971
},
7072
#"xmlsec_binary" : "/opt/local/bin/xmlsec1",
@@ -370,4 +372,4 @@ def test_assertion_consumer_service():
370372
"location"] == 'https://www.zimride.com/Shibboleth.sso/SAML2/POST'
371373

372374
if __name__ == "__main__":
373-
test_1()
375+
test_2()

0 commit comments

Comments
 (0)