italia / spid-cie-php

Software Development Kit for easy SPID/CIE access integration with simplesamlphp - developed and mantained by Michele D'Amico @damikael
https://italia.github.io/spid-cie-php/
Apache License 2.0
82 stars 39 forks source link

creare un tema invece di modificare i templates forniti da SimpleSAMLphp #23

Closed simevo closed 5 years ago

simevo commented 6 years ago

composer scarica le dipendenze in vendor; questa cartella dovrebbe essere gestita da composer, che può decidere di aggiornare i files a suo piacimento in seguito

invece:

git clone https://github.com/simevo/spid-php
git checkout develop
# eliminare tutta la parte script in composer.json
composer install
# back-up di vendor in vendor_orig:
tar cf vendor.tar && mv vendor.tar vendor_orig && tar xf vendor.tar && vendor.tar
# ripristino composer.json:
git checkout composer.json
cp config.yaml.example config.yaml
# aggiustare config.yaml se necessario ...
composer run-script post-update-cmd
diff -r vendor_orig vendor 
Solo in vendor/simplesamlphp/simplesamlphp: cert
Solo in vendor/simplesamlphp/simplesamlphp/config: authsources.php
Solo in vendor/simplesamlphp/simplesamlphp/config: config.php
Solo in vendor/simplesamlphp/simplesamlphp: log
Solo in vendor/simplesamlphp/simplesamlphp/metadata: saml20-idp-remote.php
diff -r vendor_orig/simplesamlphp/simplesamlphp/templates/selectidp-links.php vendor/simplesamlphp/simplesamlphp/templates/selectidp-links.php
2a3,4
> // customized 20180221
> 
8c10
< $this->includeAtTemplateBase('includes/header.php');
---
> 
13c15,18
<         $this->includeInlineTranslation('idpname_'.$idpentry['entityid'], $idpentry['OrganizationDisplayName']);
---
>         $this->includeInlineTranslation(
>             'idpname_'.$idpentry['entityid'],
>             $idpentry['OrganizationDisplayName']
>         );
20,49d24
<     <h2><?php echo $this->data['header']; ?></h2>
<     <form method="get" action="<?php echo $this->data['urlpattern']; ?>">
<         <input type="hidden" name="entityID" value="<?php echo htmlspecialchars($this->data['entityID']); ?>"/>
<         <input type="hidden" name="return" value="<?php echo htmlspecialchars($this->data['return']); ?>"/>
<         <input type="hidden" name="returnIDParam"
<                value="<?php echo htmlspecialchars($this->data['returnIDParam']); ?>"/>
<         <p><?php
<             echo $this->t('selectidp_full');
<             if ($this->data['rememberenabled']) {
<                 echo '<br /><input type="checkbox" name="remember" value="1" title="'.$this->t('remember').'" />'.
<                     $this->t('remember');
<             }
<             ?></p>
< <?php
<         if (!empty($this->data['preferredidp']) &&
<             array_key_exists($this->data['preferredidp'], $this->data['idplist'])
<         ) {
<             $idpentry = $this->data['idplist'][$this->data['preferredidp']];
<             echo '<div class="preferredidp">';
<             echo '    <img src="/'.$this->data['baseurlpath'].
<                  'resources/icons/experience/gtk-about.64x64.png" class="float-r" alt="'.
<                 $this->t('icon_prefered_idp').'" />';
< 
<             if (array_key_exists('icon', $idpentry) && $idpentry['icon'] !== null) {
<                 $iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($idpentry['icon']);
<                 echo '<img class="float-l" style="margin: 1em; padding: 3px; border: 1px solid #999" src="'.
<                     htmlspecialchars($iconUrl).'" />';
<             }
<             echo "\n".'       <h3 style="margin-top: 8px">'.
<                 htmlspecialchars($this->t('idpname_'.$idpentry['entityid'])).'</h3>';
51,74c26,56
<             if (!empty($idpentry['description'])) {
<                 echo '        <p>'.htmlspecialchars($this->t('idpdesc_'.$idpentry['entityid'])).'<br />';
<             }
<             echo('<button id="preferredidp" type="submit" class="btn" name="idp_'.
<                 htmlspecialchars($idpentry['entityid']).'">'.
<                 $this->t('select').'</button></p>');
<             echo '</div>';
<         }
< 
<         foreach ($this->data['idplist'] as $idpentry) {
<             if ($idpentry['entityid'] != $this->data['preferredidp']) {
<                 if (array_key_exists('icon', $idpentry) && $idpentry['icon'] !== null) {
<                     $iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($idpentry['icon']);
<                     echo '<img class="float-l" style="clear: both; margin: 1em; padding: 3px; border: 1px solid #999"'.
<                          ' src="'.htmlspecialchars($iconUrl).'" />';
<                 }
<                 echo "\n".'   <h3 style="margin-top: 8px">'.htmlspecialchars($this->t('idpname_'.$idpentry['entityid']));
<                 echo '</h3>';
< 
<                 if (!empty($idpentry['description'])) {
<                     echo '    <p>'.htmlspecialchars($this->t('idpdesc_'.$idpentry['entityid'])).'<br />';
<                 }
<                 echo '<button type="submit" class="btn" name="idp_'.htmlspecialchars($idpentry['entityid']).'">'.
<                     $this->t('select').'</button></p>';
---
> <!DOCTYPE html>
> <html lang="it">
>     <head>
>         <title lang="en">SPID Smart Button</title>
>         <meta charset="utf-8" />
>         <meta name="viewport" content="width=device-width, initial-scale=1">
>         <link rel="stylesheet" href="/myservice/css/agid-spid-enter.css">
>         <link rel="icon" type="image/ico" href="/myservice/img/favicon.ico">
>     </head>
>     <body>
> 
>         <noscript>You need to enable JavaScript to run this app.</noscript>
>         <div id="infomodal" class="modal"></div>
>         <div id="agid-spid-enter"></div>
>         <script type="text/javascript">
>         <?php
>             echo 'var config = {';
>             foreach ($this->data['idplist'] as $idpentry) {
> 
>                 $name = htmlspecialchars($this->t('idpname_'.$idpentry['entityid']));
>                 $url =  $this->data['urlpattern'] . 
>                         '?entityID=' . urlencode(htmlspecialchars($this->data['entityID'])) . 
>                         '&return=' . urlencode(htmlspecialchars($this->data['return'])) . 
>                         '&returnIDParam=' . urlencode(htmlspecialchars($this->data['returnIDParam'])) . 
>                         '&idp_' . $idpentry['entityid'] . '=' . 'idp_' . $idpentry['entityid'];
>                 $title = htmlspecialchars($this->t('idpdesc_'.$idpentry['entityid']));
>                 //$iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($idpentry['icon']);
>                 $iconUrl = $idpentry['icon'];
>                 $logo = htmlspecialchars($iconUrl);
> 
>                 echo '"'.$name.'": {"url": "'.$url.'","title": "'.$title.'","logo": "'.$logo.'"},';   
76,79c58,68
<         }
< ?>
<     </form>
< <?php $this->includeAtTemplateBase('includes/footer.php');
---
>             echo '};'
>         ?>
>         </script>
>         <script type="text/javascript" src="/myservice/js/agid-spid-enter.js" ></script>
>         <script type="text/javascript">
>             agid_spid_enter();
>             showPanel("agid-spid-panel-select");
>         </script>
> 
>     </body>
> </html>
\ Manca newline alla fine del file
Solo in vendor/simplesamlphp/simplesamlphp/www: css
Solo in vendor/simplesamlphp/simplesamlphp/www: img
Solo in vendor/simplesamlphp/simplesamlphp/www: js

questo modo di procedere confligge con quello che gli utenti si aspettano da un pacchetto composer

ci sono due problemi diversi:

se simplesamlphp evolve, questa nostra patch potrebbe diventare incompatibile (questo è per l'appunto il problema che abbiamo avuto in #6)

un approccio più corretto sarebbe un fork di simplesamlphp, che potrebbe essere https://github.com/italia/spid-sp-simplesamlphp, che però è fermo a v1.14.11 (Dec 2016) menre adesso upstream è a 1.16.0 (Jun 2018)

damikael commented 6 years ago

Lo scopo di spid-php è quello di poter allestire e configurare SimpleSAMLphp scaricandone direttamente l'ultima versione, senza dover tenere in considerazione la necessità di allineamenti. Sicuramente è corretto creare un tema specifico, invece che sovrascrivere il template di default. In tal modo sarà possibile spostare esternamente anche le modifiche che ora vengono applicate a selectidp-links.php.

https://simplesamlphp.org/docs/development/simplesamlphp-theming

damikael commented 5 years ago

Con la #43 è stato integrato lo spid-sp-access-button. Non è più necessario modificare i file di template. Le patch a simplesamlphp per renderlo conforme alle specifiche SPID sono applicate in /setup/simplesamlphp