From fc40a82954ee587e2bc97a376a6d1e34aac80e2b Mon Sep 17 00:00:00 2001 From: Lasse Birnbaum Jensen <lasse@sdu.dk> Date: Wed, 16 Jan 2008 13:45:01 +0000 Subject: [PATCH] Added option for 2 possible layouts of the idpdisco. The current link-list and the new dropdown box. Layout is choosen in the config.php. Added cookie support for prefered choice of idp. My 1st commit to simpleSAMLphp git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@161 44740490-163a-0410-bde0-09ae8108e29a --- config/config-template.php | 15 ++++++++ templates/default/en/selectidp-dropdown.php | 34 +++++++++++++++++++ .../en/{selectidp.php => selectidp-links.php} | 3 +- www/saml2/sp/idpdisco.php | 29 ++++++++++++---- www/shib13/sp/idpdisco.php | 29 +++++++++++----- 5 files changed, 93 insertions(+), 17 deletions(-) create mode 100644 templates/default/en/selectidp-dropdown.php rename templates/default/en/{selectidp.php => selectidp-links.php} (99%) diff --git a/config/config-template.php b/config/config-template.php index 3cade0846..3d1aff144 100644 --- a/config/config-template.php +++ b/config/config-template.php @@ -83,6 +83,21 @@ $config = array ( 'default-saml20-idp' => 'max.feide.no', 'default-shib13-idp' => 'urn:mace:switch.ch:aaitest:dukono.switch.ch', + /* + * IdP Discovery service look configuration. + * Wether to display a list of idp or to display a dropdown box. For many IdP' a dropdown box + * gives the best use experience. + * + * When using dropdown box a cookie is used to highlight the previously chosen IdP in the dropdown. + * This makes it easier for the user to choose the IdP + * + * Options: [links,dropdown] + * + */ + #'idpdisco.layout' => 'dropdown', + 'idpdisco.layout' => 'links', + + /* * Meta data handler. * diff --git a/templates/default/en/selectidp-dropdown.php b/templates/default/en/selectidp-dropdown.php new file mode 100644 index 000000000..9aba6e2b7 --- /dev/null +++ b/templates/default/en/selectidp-dropdown.php @@ -0,0 +1,34 @@ +<?php $this->includeAtTemplateBase('includes/header.php'); ?> + + <div id="header"> + <h1>SAML 2.0 IdP Discovery Service</h1> + <div id="poweredby"><img src="/<?php echo $data['baseurlpath']; ?>resources/icons/bino.png" alt="Bino" /></div> + </div> + + <div id="content"> + + <h2><?php if (isset($data['header'])) { echo $data['header']; } else { echo "Select your IdP"; } ?></h2> + + <p>Please select the identity provider where you want to authenticate:</p> + + <form method="get" action="<?php echo $data['urlpattern']; ?>"> + <input type="hidden" name="entityID" value="<?php echo $data['entityID']; ?>" /> + <input type="hidden" name="return" value="<?php echo $data['return']; ?>" /> + <input type="hidden" name="returnIDParam" value="<?php echo $data['returnIDParam']; ?>" /> + <select name="idpentityid"> + <?php + + foreach ($data['idplist'] AS $idpentry) { + + echo '<option value="'.$idpentry['entityid'].'"'; + if ($idpentry['entityid'] == $data['preferedidp']) echo ' selected="selected"'; + echo '>'.$idpentry['name'].'</option>'; + + } + ?> + </select> + <input type="submit" value="Select"/> + </form> + + +<?php $this->includeAtTemplateBase('includes/footer.php'); ?> diff --git a/templates/default/en/selectidp.php b/templates/default/en/selectidp-links.php similarity index 99% rename from templates/default/en/selectidp.php rename to templates/default/en/selectidp-links.php index c9ab2518e..e75bf6664 100644 --- a/templates/default/en/selectidp.php +++ b/templates/default/en/selectidp-links.php @@ -15,14 +15,13 @@ <?php foreach ($data['idplist'] AS $idpentry) { - + echo '<h3>' . $idpentry['name'] . '</h3>'; echo '<p>' . $idpentry['description'] . '<br />'; echo '[ <a href="' . $data['urlpattern'] . $idpentry['entityid'] . '">Select this IdP</a>]</p>'; } - ?> diff --git a/www/saml2/sp/idpdisco.php b/www/saml2/sp/idpdisco.php index 81e108c9a..f941e0262 100644 --- a/www/saml2/sp/idpdisco.php +++ b/www/saml2/sp/idpdisco.php @@ -41,21 +41,36 @@ try { if (isset($_GET['idpentityid'])) { $idpentityid = $_GET['idpentityid']; - + setcookie('preferedidp',$idpentityid,time()+60*60*24*90); // set cookie valid 90 days + $returnurl = SimpleSAML_Utilities::addURLparameter($return, $returnidparam . '=' . $idpentityid); SimpleSAML_Utilities::redirect($returnurl); + } $idplist = $metadata->getList('saml20-idp-remote'); -$t = new SimpleSAML_XHTML_Template($config, 'selectidp.php'); -$t->data['header'] = 'Select your identity provider'; -$t->data['idplist'] = $idplist; -$t->data['urlpattern'] = htmlentities(SimpleSAML_Utilities::selfURL() . '&idpentityid='); -$t->show(); - +if ($config->getValue('idpdisco.layout') == 'dropdown') { + $t = new SimpleSAML_XHTML_Template($config, 'selectidp-dropdown.php'); + $t->data['header'] = 'Select your identity provider'; + $t->data['idplist'] = $idplist; + $t->data['return']= $return; + $t->data['returnIDParam'] = $returnidparam; + $t->data['entityID'] = $spentityid; + $t->data['preferedidp'] = (!empty($_COOKIE['preferedidp'])) ? $_COOKIE['preferedidp'] : null; + $t->data['urlpattern'] = htmlentities(SimpleSAML_Utilities::selfURLNoQuery()); + $t->show(); +} +else +{ + $t = new SimpleSAML_XHTML_Template($config, 'selectidp-links.php'); + $t->data['header'] = 'Select your identity provider'; + $t->data['idplist'] = $idplist; + $t->data['urlpattern'] = htmlentities(SimpleSAML_Utilities::selfURL() . '&idpentityid='); + $t->show(); +} ?> \ No newline at end of file diff --git a/www/shib13/sp/idpdisco.php b/www/shib13/sp/idpdisco.php index 6c150594e..368726428 100644 --- a/www/shib13/sp/idpdisco.php +++ b/www/shib13/sp/idpdisco.php @@ -37,21 +37,34 @@ try { if (isset($_GET['idpentityid'])) { $idpentityid = $_GET['idpentityid']; - + setcookie('preferedidp',$idpentityid,time()+60*60*24*90); // set cookie valid 90 days + $returnurl = SimpleSAML_Utilities::addURLparameter($return, $returnidparam . '=' . $idpentityid); SimpleSAML_Utilities::redirect($returnurl); + } $idplist = $metadata->getList('shib13-idp-remote'); - -$t = new SimpleSAML_XHTML_Template($config, 'selectidp.php'); -$t->data['header'] = 'Select your identity provider'; -$t->data['idplist'] = $idplist; -$t->data['urlpattern'] = htmlentities(SimpleSAML_Utilities::selfURL() . '&idpentityid='); -$t->show(); - +if ($config->getValue('disco.layout') == 'dropdown') { + $t = new SimpleSAML_XHTML_Template($config, 'selectidp-dropdown.php'); + $t->data['header'] = 'Select your identity provider'; + $t->data['idplist'] = $idplist; + $t->data['return']= $return; + $t->data['returnIDParam'] = $returnidparam; + $t->data['entityID'] = $spentityid; + $t->data['preferedidp'] = (!empty($_COOKIE['preferedidp'])) ? $_COOKIE['preferedidp'] : null; + $t->data['urlpattern'] = htmlentities(SimpleSAML_Utilities::selfURLNoQuery()); +} +else +{ + $t = new SimpleSAML_XHTML_Template($config, 'selectidp-links.php'); + $t->data['header'] = 'Select your identity provider'; + $t->data['idplist'] = $idplist; + $t->data['urlpattern'] = htmlentities(SimpleSAML_Utilities::selfURL() . '&idpentityid='); + $t->show(); +} ?> \ No newline at end of file -- GitLab