Skip to content

Commit ebb6d35

Browse files
committed
SAMLBackend check context for discovery service base URL
The SAMLBackend start_auth() and disco_query() methods have been modified so that disco_query() can check the context for the base URL to use for the discovery service. This allows request microservices the opportunity to set the base URL for the discovery service to use.
1 parent 49da5d4 commit ebb6d35

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/satosa/backends/saml2.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class SAMLBackend(BackendModule, SAMLBaseModule):
4040
A saml2 backend module (acting as a SP).
4141
"""
4242
KEY_DISCO_SRV = 'disco_srv'
43+
KEY_SAML_DISCOVERY_SERVICE_URL = 'saml_discovery_service_url'
4344
KEY_SP_CONFIG = 'sp_config'
4445
VALUE_ACR_COMPARISON_DEFAULT = 'exact'
4546

@@ -102,9 +103,9 @@ def start_auth(self, context, internal_req):
102103
entity_id = idps[0]
103104
return self.authn_request(context, entity_id)
104105

105-
return self.disco_query()
106+
return self.disco_query(context)
106107

107-
def disco_query(self):
108+
def disco_query(self, context):
108109
"""
109110
Makes a request to the discovery server
110111
@@ -116,8 +117,17 @@ def disco_query(self):
116117
:param internal_req: The request
117118
:return: Response
118119
"""
119-
return_url = self.sp.config.getattr("endpoints", "sp")["discovery_response"][0][0]
120-
loc = self.sp.create_discovery_service_request(self.discosrv, self.sp.config.entityid, **{"return": return_url})
120+
endpoints = self.sp.config.getattr("endpoints", "sp")
121+
return_url = endpoints["discovery_response"][0][0]
122+
123+
disco_url = context.get_decoration(self.KEY_SAML_DISCOVERY_SERVICE_URL)
124+
if not disco_url:
125+
disco_url = self.discosrv
126+
127+
loc = self.sp.create_discovery_service_request(
128+
disco_url,
129+
self.sp.config.entityid, **{"return": return_url})
130+
121131
return SeeOther(loc)
122132

123133
def construct_requested_authn_context(self, entity_id):

0 commit comments

Comments
 (0)