diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index 156ce1f93d1193da0e84a71e23c8b9de394044dd..d426c7ee7f200dfeb39e0e37405eb050f700d526 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -137,6 +137,31 @@ class SimpleSAML_Auth_Simple {
 		return $session->getAttributes();
 	}
 
+
+	/**
+	 * Retrieve an URL that can be used to log the user in.
+	 *
+	 * @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 getLoginURL($returnTo = NULL) {
+
+		if ($returnTo === NULL) {
+			$returnTo = SimpleSAML_Utilities::selfURL();
+		}
+
+		$login = SimpleSAML_Module::getModuleURL('core/as_login.php');
+		$login = SimpleSAML_Utilities::addURLparameter($login, array(
+			'AuthId' => $this->authSource,
+			'ReturnTo' => $returnTo,
+		));
+
+		return $login;
+	}
+
 }
 
 ?>
\ No newline at end of file
diff --git a/modules/core/www/as_login.php b/modules/core/www/as_login.php
new file mode 100644
index 0000000000000000000000000000000000000000..5a02bdbfe2a1ad69bdd122f69a8e547e11a72689
--- /dev/null
+++ b/modules/core/www/as_login.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Endpoint for logging in with an authentication source.
+ *
+ * @package simpleSAMLphp
+ * @version $Id$
+ */
+
+if (!is_string($_REQUEST['ReturnTo'])) {
+	throw new SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
+}
+
+if (!is_string($_REQUEST['AuthId'])) {
+	throw new SimpleSAML_Error_BadRequest('Missing AuthId parameter.');
+}
+
+$as = new SimpleSAML_Auth_Simple($_REQUEST['AuthId']);
+$as->requireAuth(array(
+	'url' => $_REQUEST['ReturnTo'],
+));
+
+SimpleSAML_Utilities::redirect($_REQUEST['ReturnTo']);