From 585b50d7d9b991b16552cce796546b42ba5b70e8 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Fri, 16 Oct 2009 11:04:44 +0000
Subject: [PATCH] SimpleSAML_Auth_Simple: Add getLogoutURL().
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1861 44740490-163a-0410-bde0-09ae8108e29a
---
lib/SimpleSAML/Auth/Simple.php | 26 ++++++++++++++++++++++++++
modules/core/www/as_logout.php | 19 +++++++++++++++++++
2 files changed, 45 insertions(+)
create mode 100644 modules/core/www/as_logout.php
diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index f3eed669a..e0d6aedb6 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -163,6 +163,32 @@ class SimpleSAML_Auth_Simple {
return $login;
}
+
+ /**
+ * Retrieve an URL that can be used to log the user out.
+ *
+ * @param string|NULL $returnTo
+ * The page the user should be returned to afterwards. If this parameter
+ * is NULL, the user will be returned to the current page.
+ * @return string
+ * An URL which is suitable for use in link-elements.
+ */
+ public function getLogoutURL($returnTo = NULL) {
+ assert('is_null($returnTo) || is_string($returnTo)');
+
+ if ($returnTo === NULL) {
+ $returnTo = SimpleSAML_Utilities::selfURL();
+ }
+
+ $logout = SimpleSAML_Module::getModuleURL('core/as_logout.php');
+ $logout = SimpleSAML_Utilities::addURLparameter($logout, array(
+ 'AuthId' => $this->authSource,
+ 'ReturnTo' => $returnTo,
+ ));
+
+ return $logout;
+ }
+
}
?>
\ No newline at end of file
diff --git a/modules/core/www/as_logout.php b/modules/core/www/as_logout.php
new file mode 100644
index 000000000..5ae8a39c3
--- /dev/null
+++ b/modules/core/www/as_logout.php
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * Endpoint for logging out in with an authentication source.
+ *
+ * @package simpleSAMLphp
+ * @version $Id$
+ */
+
+if (!isset($_REQUEST['ReturnTo']) || !is_string($_REQUEST['ReturnTo'])) {
+ throw new SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
+}
+
+if (!isset($_REQUEST['AuthId']) || !is_string($_REQUEST['AuthId'])) {
+ throw new SimpleSAML_Error_BadRequest('Missing AuthId parameter.');
+}
+
+$as = new SimpleSAML_Auth_Simple($_REQUEST['AuthId']);
+$as->logout($_REQUEST['ReturnTo']);
--
GitLab