Skip to content

Commit 5d7f27e

Browse files
Merge pull request #434 from c00kiemon5ter/feature-hide-assertion-consumer-service
Add configuration option to hide assertion consumer service on authn requests This kind of functionality is required for the eIDAS SAML profile that dictates that > eIDAS-Connectors SHOULD NOT provide AssertionConsumerServiceURL.
2 parents 6d22008 + 8ca067d commit 5d7f27e

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/saml2/client_base.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -235,26 +235,30 @@ def create_authn_request(self, destination, vorg="", scoping=None,
235235

236236
args = {}
237237

238-
try:
239-
args["assertion_consumer_service_url"] = kwargs[
240-
"assertion_consumer_service_urls"][0]
241-
del kwargs["assertion_consumer_service_urls"]
242-
except KeyError:
238+
if self.config.getattr('hide_assertion_consumer_service', 'sp'):
239+
args["assertion_consumer_service_url"] = None
240+
binding = None
241+
else:
243242
try:
244243
args["assertion_consumer_service_url"] = kwargs[
245-
"assertion_consumer_service_url"]
246-
del kwargs["assertion_consumer_service_url"]
244+
"assertion_consumer_service_urls"][0]
245+
del kwargs["assertion_consumer_service_urls"]
247246
except KeyError:
248247
try:
249-
args["assertion_consumer_service_index"] = str(
250-
kwargs["assertion_consumer_service_index"])
251-
del kwargs["assertion_consumer_service_index"]
248+
args["assertion_consumer_service_url"] = kwargs[
249+
"assertion_consumer_service_url"]
250+
del kwargs["assertion_consumer_service_url"]
252251
except KeyError:
253-
if service_url_binding is None:
254-
service_urls = self.service_urls(binding)
255-
else:
256-
service_urls = self.service_urls(service_url_binding)
257-
args["assertion_consumer_service_url"] = service_urls[0]
252+
try:
253+
args["assertion_consumer_service_index"] = str(
254+
kwargs["assertion_consumer_service_index"])
255+
del kwargs["assertion_consumer_service_index"]
256+
except KeyError:
257+
if service_url_binding is None:
258+
service_urls = self.service_urls(binding)
259+
else:
260+
service_urls = self.service_urls(service_url_binding)
261+
args["assertion_consumer_service_url"] = service_urls[0]
258262

259263
try:
260264
args["provider_name"] = kwargs["provider_name"]

src/saml2/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"name_id_format_allow_create",
7777
"logout_requests_signed",
7878
"requested_attribute_name_format",
79+
"hide_assertion_consumer_service",
7980
"force_authn",
8081
]
8182

0 commit comments

Comments
 (0)