From e79b36e7dc75fa382fd2a521589f467dd5efaacd Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Fri, 25 Sep 2009 07:53:59 +0000
Subject: [PATCH] www/saml2/idp/SSOService: Save RelayState in request restart
 URL.

Fixes issue 213

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1787 44740490-163a-0410-bde0-09ae8108e29a
---
 www/saml2/idp/SSOService.php | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/www/saml2/idp/SSOService.php b/www/saml2/idp/SSOService.php
index 5ade30fd6..99e2ad771 100644
--- a/www/saml2/idp/SSOService.php
+++ b/www/saml2/idp/SSOService.php
@@ -271,6 +271,9 @@ if (isset($_REQUEST['SAMLRequest'])) {
 		'Issuer' => $_GET['spentityid'],
 	);
 
+	if (isset($_GET['RelayState'])) {
+		$requestcache['RelayState'] = $_GET['RelayState'];
+	}
 
 } else {
 	SimpleSAML_Utilities::fatalError($session->getTrackID(), 'SSOSERVICEPARAMS');
@@ -329,11 +332,16 @@ if($needAuth && !$isPassive) {
 		/* The user will be redirected to this URL if the session is lost. This will cause an
 		 * unsoliced authentication response to be sent to the SP.
 		 */
+		$sessionLostParams = array(
+			'spentityid' => $requestcache['Issuer'],
+			);
+		if (isset($requestcache['RelayState'])) {
+			$sessionLostParams['RelayState'] = $requestcache['RelayState'];
+		}
+
 		$sessionLostURL = SimpleSAML_Utilities::addURLparameter(
 			$metadata->getGenerated('SingleSignOnService', 'saml20-idp-hosted'),
-			array(
-				'spentityid' => $requestcache['Issuer'],
-			));
+			$sessionLostParams);
 
 		$hints = array(
 			'SPMetadata' => $metadata->getMetaData($requestcache['Issuer'], 'saml20-sp-remote'),
-- 
GitLab