From eed4950aa42d09c88fdae9e98f3851f83d4d3f08 Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Mon, 31 Aug 2015 14:57:27 +0200
Subject: [PATCH] Throw an exception in SimpleSAML_Auth_Simple when the auth
 source cannot be found. This avoids trying to access a method in an object
 that's actually null.

---
 lib/SimpleSAML/Auth/Simple.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index e1ece6997..eca1339c2 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -33,7 +33,11 @@ class SimpleSAML_Auth_Simple {
 	 * @return SimpleSAML_Auth_Source  The authentication source.
 	 */
 	public function getAuthSource() {
-		return SimpleSAML_Auth_Source::getById($this->authSource);
+		$as = SimpleSAML_Auth_Source::getById($this->authSource);
+		if ($as === null) {
+			throw new SimpleSAML_Error_Exception('Invalid authentication source: '.$this->authSource);
+		}
+		return $as;
 	}
 
 
-- 
GitLab