Skip to content

Commit 082dfc7

Browse files
committed
adding returnUrl parameter to singleLogoutService of IdP
1 parent 4380bf1 commit 082dfc7

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ This is the ``settings.json`` file:
304304
"singleLogoutService": {
305305
// URL Location of the IdP where SLO Request will be sent.
306306
"url": "https://app.onelogin.com/trust/saml2/http-redirect/slo/<onelogin_connector_id>",
307+
// URL Location where the <Response> from the SP will returned (after IdP-initiated logout)
308+
// OPTIONAL: only specify if different from url parameter
309+
"returnUrl": "<idp-domain>/slo_return/"
307310
// SAML protocol binding to be used when returning the <Response>
308311
// message. OneLogin Toolkit supports the HTTP-Redirect binding
309312
// only for this endpoint.

src/onelogin/saml2/auth.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def process_slo(self, keep_local_session=False, request_id=None, delete_session_
190190
if security['logoutResponseSigned']:
191191
self.add_response_signature(parameters, security['signatureAlgorithm'])
192192

193-
return self.redirect_to(self.get_slo_url(), parameters)
193+
return self.redirect_to(self.get_slo_return_url(), parameters)
194194
else:
195195
self.__errors.append('invalid_binding')
196196
raise OneLogin_Saml2_Error(
@@ -468,6 +468,16 @@ def get_slo_url(self):
468468
if 'url' in idp_data['singleLogoutService']:
469469
return idp_data['singleLogoutService']['url']
470470

471+
def get_return_slo_url(self):
472+
"""
473+
Gets the SLO return URL for IdP-initiated logout.
474+
475+
:returns: an URL, the SLO return endpoint of the IdP
476+
:rtype: string
477+
"""
478+
slo_data = self.__settings.get_idp_data()['singeLogoutService']
479+
return slo_data.get('returnUrl', self.get_slo_url())
480+
471481
def add_request_signature(self, request_data, sign_algorithm=OneLogin_Saml2_Constants.RSA_SHA1):
472482
"""
473483
Builds the Signature of the SAML Request.

src/onelogin/saml2/logout_response.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,13 @@ def build(self, in_response_to):
162162

163163
uid = OneLogin_Saml2_Utils.generate_unique_id()
164164
issue_instant = OneLogin_Saml2_Utils.parse_time_to_SAML(OneLogin_Saml2_Utils.now())
165+
destination = idp_data['singeLogoutService'].get('returnUrl', idp_data['singeLogoutService']['url'])
165166

166167
logout_response = OneLogin_Saml2_Templates.LOGOUT_RESPONSE % \
167168
{
168169
'id': uid,
169170
'issue_instant': issue_instant,
170-
'destination': idp_data['singleLogoutService']['url'],
171+
'destination': destination,
171172
'in_response_to': in_response_to,
172173
'entity_id': sp_data['entityId'],
173174
'status': "urn:oasis:names:tc:SAML:2.0:status:Success"

0 commit comments

Comments
 (0)