diff --git a/modules/core/www/as_login.php b/modules/core/www/as_login.php
index 55ab960bdd6804bf41e10c1d6329466682c67bbb..143dde6c1cd7b87b7b58f9dbdac21b1b64a481f6 100644
--- a/modules/core/www/as_login.php
+++ b/modules/core/www/as_login.php
@@ -15,9 +15,24 @@ if (!is_string($_REQUEST['AuthId'])) {
 	throw new SimpleSAML_Error_BadRequest('Missing AuthId parameter.');
 }
 
-$as = new SimpleSAML_Auth_Simple($_REQUEST['AuthId']);
-$as->requireAuth(array(
+/*
+ * Setting up the options for the requireAuth() call later..
+ */
+$options = array(
 	'ReturnTo' => $_REQUEST['ReturnTo'],
-));
+);
+
+/*
+ * Allows a saml:idp query string parameter specify the IdP entity ID to be used
+ * as used by the DiscoJuice embedded client.
+ */
+if (!empty($_REQUEST['saml:idp'])) {
+	$options['saml:idp'] = $_REQUEST['saml:idp'];
+}
+
+
+
+$as = new SimpleSAML_Auth_Simple($_REQUEST['AuthId']);
+$as->requireAuth($options);
 
 SimpleSAML_Utilities::redirect($_REQUEST['ReturnTo']);