Skip to content

Commit 47cbd12

Browse files
author
ivan
committed
Add option to hide assertion consumer service on authn requests
When 'hide_assertion_consumer_service' is set to 'true', then the AuthnRequest will not include the 'AssertionConsumerServiceURL' and 'ProtocolBinding' attributes.
1 parent a490e47 commit 47cbd12

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"name_id_format",
7676
"name_id_format_allow_create",
7777
"logout_requests_signed",
78-
"requested_attribute_name_format"
78+
"requested_attribute_name_format",
79+
"hide_assertion_consumer_service",
7980
]
8081

8182
AA_IDP_ARGS = [

0 commit comments

Comments
 (0)