diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c9472c5fa28d523a1b0b55242794de9bf065502..dd5161f9cf539e3be4776b536a1b09205a4cd756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,9 @@ All notable changes to this project will be documented in this file. - Changed the way of getting attribute names for interfaces: through internal attribute names in perun_attributes.php config - Return sorted eduPersonEntitlement - Don't show previous selection when user show all entries on the discovery page -- ListOfSps - Don't show the description by default +- ListOfSps + - Don't show the description by default + - Added required attribute 'listOfSps.serviceNameAttr' !!! ## [v3.9.0] #### Added diff --git a/config-templates/module_perun.php b/config-templates/module_perun.php index c1ef791b3657ad1bd4a30eaa60256a12a6ef3580..be3b350c6583470a61e5916decfc4b66aa5b85dc 100644 --- a/config-templates/module_perun.php +++ b/config-templates/module_perun.php @@ -144,6 +144,11 @@ $config = [ * Specify attribute name for facility attribute proxy identifiers */ 'listOfSps.perunProxyIdentifierAttr' => '', + + /** + * Specify attribute name for facility attribute with service name + */ + 'listOfSps.serviceNameAttr' => '', /** * Specify attribute name for facility attribute with loginUrL for service diff --git a/lib/ListOfSps.php b/lib/ListOfSps.php index 11f75f20297b9ceb89d59019b2b28bea89e1297d..5037759a9b6d5d14f4d1d994267bd6046573c8ee 100644 --- a/lib/ListOfSps.php +++ b/lib/ListOfSps.php @@ -25,15 +25,13 @@ class ListOfSps } } - public static function printServiceName($service) + public static function printServiceName($name, $loginURL = null) { - if (empty($service['loginURL']['value']) - ) { - return $service['facility']->getName(); + if (empty($loginURL)) { + return $name; } - return "<a class='customLink' href='" . $service['loginURL']['value'] . "'>" . - $service['facility']->getName() . "</a>"; + return "<a class='customLink' href='" . htmlspecialchars($loginURL) . "'>" . htmlspecialchars($name) . "</a>"; } public static function printAttributeValue($attribute, $service, $attr) diff --git a/templates/listOfSps-tpl.php b/templates/listOfSps-tpl.php index 577d0c94adbc711cab9cf8a737e7abda42860d50..0552c8322bca717f49d926f88861a59c118bd885 100644 --- a/templates/listOfSps-tpl.php +++ b/templates/listOfSps-tpl.php @@ -115,7 +115,9 @@ $this->includeAtTemplateBase('includes/header.php'); continue; } echo '<tr>'; - echo '<td>' . ListOfSps::printServiceName($service) . '</td>'; + echo '<td>' + . ListOfSps::printServiceName($service['name']['value'], $service['loginURL']['value'] ?? null) + . '</td>'; if (array_key_exists($service['facility']->getID(), $samlServices)) { echo '<td>' . $this->t('{perun:listOfSps:saml}') . '</td>'; } else { diff --git a/www/listOfSps.php b/www/listOfSps.php index 6ce85b39a3b8f16493123959d0dee34289cab461..9ca54f1c89799313c38f8d47c8b63de38152c3a4 100644 --- a/www/listOfSps.php +++ b/www/listOfSps.php @@ -11,6 +11,7 @@ const PROXY_IDENTIFIER = 'listOfSps.proxyIdentifier'; const ATTRIBUTES_DEFINITIONS = 'listOfSps.attributesDefinitions'; const SHOW_OIDC_SERVICES = 'listOfSps.showOIDCServices'; +const PERUN_SERVICE_NAME_ATTR_NAME = 'listOfSps.serviceNameAttr'; const PERUN_PROXY_IDENTIFIER_ATTR_NAME = 'listOfSps.perunProxyIdentifierAttr'; const PERUN_LOGIN_URL_ATTR_NAME = 'listOfSps.loginURLAttr'; const PERUN_TEST_SP_ATTR_NAME = 'listOfSps.isTestSpAttr'; @@ -62,6 +63,13 @@ if ($showOIDCServices && empty($perunOidcClientIdAttr)) { ); } +$perunServiceNameAttr = $conf->getString(PERUN_SERVICE_NAME_ATTR_NAME, null); +if (empty($perunServiceNameAttr)) { + throw new Exception( + 'perun:listOfSps: missing mandatory config option \'' + . PERUN_SERVICE_NAME_ATTR_NAME . '\'.' + ); +} $perunLoginURLAttr = $conf->getString(PERUN_LOGIN_URL_ATTR_NAME, null); $perunTestSpAttr = $conf->getString(PERUN_TEST_SP_ATTR_NAME, null); $perunShowOnServiceListAttr @@ -76,6 +84,7 @@ $facilities $attrNames = []; array_push($attrNames, $perunSaml2EntityIdAttr); +array_push($attrNames, $perunServiceNameAttr); if (!empty($perunOidcClientIdAttr)) { array_push($attrNames, $perunOidcClientIdAttr); } @@ -106,6 +115,7 @@ foreach ($facilities as $facility) { if (!empty($facilityAttributes[$perunSaml2EntityIdAttr]['value'])) { $samlServices[$facility->getId()] = [ 'facility' => $facility, + 'name' => $facilityAttributes[$perunServiceNameAttr], 'loginURL' => $facilityAttributes[$perunLoginURLAttr], 'showOnServiceList' => $facilityAttributes[$perunShowOnServiceListAttr], 'facilityAttributes' => $facilityAttributes @@ -118,6 +128,7 @@ foreach ($facilities as $facility) { if ($showOIDCServices && !empty($facilityAttributes[$perunOidcClientIdAttr]['value'])) { $oidcServices[$facility->getId()] = [ 'facility' => $facility, + 'name' => $facilityAttributes[$perunServiceNameAttr], 'loginURL' => $facilityAttributes[$perunLoginURLAttr], 'showOnServiceList' => $facilityAttributes[$perunShowOnServiceListAttr], 'facilityAttributes' => $facilityAttributes @@ -137,6 +148,7 @@ $statistics['oidcTestServicesCount'] = $oidcTestServicesCount; $attributesToShow = []; foreach ($attrNames as $attrName) { if ($attrName !== $perunLoginURLAttr + && $attrName !== $perunServiceNameAttr && $attrName !== $perunShowOnServiceListAttr && $attrName !== $perunTestSpAttr && $attrName !== $perunOidcClientIdAttr @@ -161,7 +173,7 @@ if (isset($_GET['output']) && $_GET['output'] === 'json') { $json['statistics']['oidcTestServicesCount'] = $statistics['oidcTestServicesCount']; foreach ($allServices as $service) { $a = []; - $a['name'] = $service['facility']->getName(); + $a['name'] = $service['facilityAttributes'][$perunServiceNameAttr]['value']; if (array_key_exists($service['facility']->getID(), $samlServices)) { $a['authenticationProtocol'] = 'SAML';