diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index e1ece69972f76b46363ca5b36289df6dc71ae6ba..eca1339c2518558284a2dc625f74bfb585cf9ba8 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;
 	}