Changes between Initial Version and Version 1 of spiam2018


Ignore:
Timestamp:
Sep 4, 2018, 4:50:32 AM (6 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • spiam2018

    v1 v1  
     1= Shibboleth SP on Ubuntu Linux LTS 18.04 =
     2
     3Installation assumes you have already installed Ubuntu Server 18.04 with default configuration and has a public IP connectivity with DNS setup
     4
     5Lets Assume your server hostname as '''sp.YOUR-DOMAIN'''
     6
     7All commands are to be run as root and you may use `sudo su` to become root
     8
     91. Install the packages required:
     10*
     11{{{
     12apt install apache2 ntp ca-certificates vim openssl binutils
     13}}}   
     14
     152. Modify `/etc/hosts`:
     16*
     17{{{
     18vim /etc/hosts
     19}}}
     20{{{
     21     127.0.0.1 sp.YOUR-DOMAIN sp
     22}}}
     23(Replace `sp.YOUR-DOMAIN` with your sp FQDN)
     24
     25== Install Shibboleth Service Provider ==
     26
     273. Install dependancies to overcome issues with libcurl libraries. ( Credits: [https://depts.washington.edu/bitblog/2018/06/libcurl3-libcurl4-shibboleth-php-curl-ubuntu-18-04/ Josh L.'s Blog] )
     28*
     29{{{
     30     apt install liblog4shib1v5 libxerces-c3.2 libxml-security-c17v5 libcurl3
     31     cp /usr/lib/x86_64-linux-gnu/libcurl.so.4.5.0 /usr/lib/x86_64-linux-gnu/libcurl3.so.4.5.0
     32     apt-get install libcurl4
     33     mkdir ~/temp
     34     cd ~/temp
     35     apt-get download libxmltooling7 # Ignore the warnings
     36     ar x libxmltooling7_1.6.4-1ubuntu2_amd64.deb
     37     tar xf control.tar.xz
     38     sed -i -e 's/libcurl3 (>= 7.16.2)/libcurl4/g' control
     39     tar -cJvf control.tar.xz control md5sums shlibs triggers
     40     ar rcs libxmltooling-local.deb debian-binary control.tar.xz data.tar.xz
     41     dpkg -i libxmltooling-local.deb
     42     mkdir /etc/systemd/system/shibd.service.d
     43}}}
     44* Create the following script to override defaults,
     45*
     46{{{
     47vim /etc/systemd/system/shibd.service.d/override.conf`
     48}}}
     49{{{
     50     [Service]
     51     Environment="LD_PRELOAD=libcurl3.so.4.5.0"
     52}}}
     53   
     544. Install Shibboleth SP:
     55{{{
     56     apt install libapache2-mod-shib2 libapache2-mod-php
     57}}}
     58
     59From this point the location of the SP directory is: `/etc/shibboleth`
     60
     61== Configuration Instructions ==
     62
     63=== Configure Apache2 ===
     64
     655. These configurations are based for test purposes with self generated ssl certificates.
     66   If you have purchased ssl certificate from a commercial CA substitute those with the self signed files.
     67   If you wish to get '''letsencrypt''' certificates //Skip //to '''Step 10'''.
     68
     69   Create a Certificate and a Key self-signed for HTTPS:
     70* ```openssl req -x509 -newkey rsa:4096 -keyout /etc/ssl/private/ssl-sp.key -out /etc/ssl/certs/ssl-sp.crt -nodes -days 1095```
     71
     726. Modify the file ```/etc/apache2/sites-available/sp-ssl.conf``` as follows:
     73
     74   ```apache
     75   <IfModule mod_ssl.c>
     76      SSLStaplingCache        shmcb:/var/run/ocsp(128000)
     77      <VirtualHost _default_:443>
     78        ServerName sp.YOUR-DOMAIN:443
     79        ServerAdmin admin@YOUR-DOMAIN
     80        DocumentRoot /var/www/html
     81        ...
     82        SSLEngine On
     83       
     84        SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
     85        SSLCipherSuite "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"
     86
     87        SSLHonorCipherOrder on
     88
     89        # Disable SSL Compression
     90        SSLCompression Off
     91       
     92        # OCSP Stapling, only in httpd/apache >= 2.3.3
     93        SSLUseStapling          on
     94        SSLStaplingResponderTimeout 5
     95        SSLStaplingReturnResponderErrors off
     96       
     97        # Enable HTTP Strict Transport Security with a 2 year duration
     98        Header always set Strict-Transport-Security "max-age=63072000;includeSubDomains;preload"
     99        ...
     100        SSLCertificateFile /etc/ssl/certs/ssl-sp.crt
     101        SSLCertificateKeyFile /etc/ssl/private/ssl-sp.key
     102        SSLCertificateChainFile /root/certificates/ssl-ca.pem
     103        ...
     104      </VirtualHost>
     105   </IfModule>
     106   ```
     107
     1087. Enable **proxy_http**, **SSL** and **headers** Apache2 modules:
     109   * ```a2enmod proxy_http ssl headers alias include negotiation```
     110   * ```a2ensite sp-ssl.conf```
     111   * ```systemctl restart apache2```
     112
     1138. Configure Apache2 to open port **80** only for localhost:
     114   * ```vim /etc/apache2/ports.conf```
     115
     116     ```apache
     117     # If you just change the port or add more ports here, you will likely also
     118     # have to change the VirtualHost statement in
     119     # /etc/apache2/sites-enabled/000-default.conf
     120
     121     Listen 127.0.0.1:80
     122 
     123     <IfModule ssl_module>
     124       Listen 443
     125     </IfModule>
     126   
     127     <IfModule mod_gnutls.c>
     128       Listen 443
     129     </IfModule>
     130     ```
     1319. Configure Apache2 to redirect all on HTTPS:
     132   * ```vim /etc/apache2/sites-enabled/000-default.conf```
     133   
     134     ```apache
     135     <VirtualHost *:80>
     136        ServerName "sp.YOUR-DOMAIN"
     137        Redirect permanent "/" "https://sp.YOUR-DOMAIN/"
     138        RedirectMatch permanent ^/(.*)$ https://sp.YOUR-DOMAIN/$1
     139     </VirtualHost>
     140     ```
     14110. **Let'sencrypt** setup (*Skip this step if you already configured SSL with self signed or CA provided certificates*)
     142
     143    Disable the default configuration
     144    * `cd /etc/apache2/sites-available/`
     145    * `a2dissite 000-default.conf`
     146    * `systemctl reload apache2`
     147
     148    Create a new conf file as `sp.conf`
     149
     150    * `cp 000-default.conf sp.conf`
     151
     152    Edit `sp.conf` with following
     153
     154   * `vim sp.conf`
     155
     156```apache
     157<VirtualHost *:80>
     158 
     159        ServerName sp.YOUR-DOMAIN
     160        ServerAdmin YOUR-Email
     161        DocumentRoot /var/www/html
     162       
     163        ErrorLog ${APACHE_LOG_DIR}/error.log
     164        CustomLog ${APACHE_LOG_DIR}/access.log combined
     165
     166</VirtualHost>
     167```
     168
     169   Enable sp site by,
     170
     171   * `a2ensite sp`
     172   
     173   and restart Apache
     174
     175   * `systemctl reload apache2`
     176   
     177   
     178   Install Letsencypt and enable https
     179
     180```bash
     181add-apt-repository ppa:certbot/certbot
     182apt install python-certbot-apache
     183certbot --apache -d sp.YOUR-DOMAIN
     184```
     185```
     186Plugins selected: Authenticator apache, Installer apache
     187Enter email address (used for urgent renewal and security notices) (Enter 'c' to
     188cancel): YOU@YOUR-DOMAIN
     189
     190- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     191Please read the Terms of Service at
     192https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
     193agree in order to register with the ACME server at
     194https://acme-v02.api.letsencrypt.org/directory
     195- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     196(A)gree/(C)ancel: A
     197
     198- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     199Would you be willing to share your email address with the Electronic Frontier
     200Foundation, a founding partner of the Let's Encrypt project and the non-profit
     201organization that develops Certbot? We'd like to send you email about our work
     202encrypting the web, EFF news, campaigns, and ways to support digital freedom.
     203- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     204(Y)es/(N)o: Y
     205
     206Obtaining a new certificate
     207Performing the following challenges:
     208http-01 challenge for sp.YOUR_DOMAIN
     209Waiting for verification...
     210Cleaning up challenges
     211Created an SSL vhost at /etc/apache2/sites-available/sp-le-ssl.conf
     212Enabled Apache socache_shmcb module
     213Enabled Apache ssl module
     214Deploying Certificate to VirtualHost /etc/apache2/sites-available/sp-le-ssl.conf
     215Enabling available site: /etc/apache2/sites-available/sp-le-ssl.conf
     216
     217
     218Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
     219- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     2201: No redirect - Make no further changes to the webserver configuration.
     2212: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
     222new sites, or if you're confident your site works on HTTPS. You can undo this
     223change by editing your web server's configuration.
     224- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     225Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
     226Redirecting vhost in /etc/apache2/sites-enabled/sp.conf to ssl vhost in /etc/apache2/sites-available/sp-le-ssl.conf
     227
     228- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     229Congratulations! You have successfully enabled https://sp.YOUR-DOMAIN
     230
     231```
     232
     233
     234### Configure Shibboleth SP
     235
     236
     237
     23811. Download Federation Metadata Signing Certificate: (If its available)
     239   * ```cd /etc/shibboleth/```
     240   * ```wget https://LEARN-Test-federation/signning-key.pem```
     241
     242
     24312. Edit ```shibboleth2.xml``` opportunely:
     244   * ```vim /etc/shibboleth/shibboleth2.xml```
     245
     246     ```bash
     247     ...
     248     <ApplicationDefaults entityID="https://sp.YOUR-DOMAIN/shibboleth"
     249          REMOTE_USER="eppn persistent-id targeted-id">
     250     ...
     251     <Sessions lifetime="28800" timeout="3600" checkAddress="false" handlerSSL="true" cookieProps="https">
     252     ...
     253     <SSO discoveryProtocol="SAMLDS" discoveryURL="https://fds-training.ac.lk">
     254        SAML2
     255     </SSO>
     256     ...
     257     <MetadataProvider type="XML" uri="https://fr-training.ac.lk/rr3/metadata/federation/FR-training/metadata.xml" legacyOrgName="true" backingFilePath="test-metadata.xml" reloadInterval="600">
     258           <!-- remove this comment if the signning key is available
     259           <MetadataFilter type="Signature" certificate="signning-key.pem"/>
     260           -->
     261           <MetadataFilter type="RequireValidUntil" maxValidityInterval="864000" />
     262     </MetadataProvider>
     263     ```
     26413. Create SP metadata credentials:
     265   * ```/usr/sbin/shib-keygen```
     266   * ```shibd -t /etc/shibboleth/shibboleth2.xml``` (Check Shibboleth configuration)
     267
     26814. Enable Shibboleth Apache2 configuration:
     269   * ```a2enmod shib2```
     270   * ```systemctl reload apache2.service ```
     271
     27215. Now you are able to reach your Shibboleth SP Metadata on:
     273   * ```https://sp.YOUR-DOMAIN/Shibboleth.sso/Metadata```
     274   (change ```sp.YOUR-DOMAIN``` to you SP full qualified domain name)
     275
     27616. Register you SP on LEARN test federation:
     277   * Go to ```https://fr-training.ac.lk/rr3/providers/sp_registration``` and continue registration with pasting the content of your metadata file
     278
     279
     280### Configure an example federated resouce "secure"
     281
     28217. Create the Apache2 configuration for the application:
     283   * ```sudo su -```
     284
     285   * ```vim /etc/apache2/site-available/secure.conf```
     286 
     287     ```bash
     288     RedirectMatch    ^/$  /secure
     289
     290     <Location /secure>
     291       Authtype shibboleth
     292       ShibRequireSession On
     293       require valid-user
     294     </Location>
     295     ```
     296
     29718. Create the "```secure```" application into the DocumentRoot:
     298   * ```mkdir /var/www/html/secure```
     299
     300   * ```vim /var/www/html/secure/index.php```
     301
     302     ```html
     303     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     304     <html>
     305       <head>
     306         <title></title>
     307         <meta name="GENERATOR" content="Quanta Plus">
     308         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     309       </head>
     310       <body>
     311         <p>
     312          <a href="https://YOUR-DOMAIN/privacy.html">Privacy Policy</a>
     313         </p>
     314         <?php
     315         
     316         foreach ($_SERVER as $key => $value){
     317            print $key." = ".$value."<br>";
     318         }
     319         /*foreach ($_ENV as $key => $value){
     320            print $key." = ".$value."<br>";
     321         }
     322         foreach ($_COOKIE as $key => $value){
     323            print $key." = ".$value."<br>";
     324         }*/
     325         ?>
     326       </body>
     327     </html>
     328     ```
     329
     33019. Install needed packages:
     331   * ```apt istall libapache2-mod-php```
     332
     333   * ```systemctl restart apache2.service```
     334
     335
     336### Enable Attribute Support on Shibboleth SP
     33720. Enable attribute by remove comment from the related content into "```/etc/shibboleth/attribute-map.xml```"
     338    Disable First deprecated/incorrect version of ```persistent-id``` from ```attribute-map.xml```
     339   
     340### Enable Single Logout
     341
     34221. Change <Logout> element in /etc/shibboleth/shibboleth2.xml. They get passed as attributes to the SAML2 LogoutInitiator that gets created by the Logout element.  The fully unfolded configuration with settings identical to default is:
     343```xml
     344<Logout asynchronous="true" outgoingBindings="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST urn:oasis:names:tc:SAML:2.0:bindings:SOAP">
     345  SAML2 Local
     346</Logout>
     347```
     348Setting asynchronous="false" would make the flow return back to the SP (this otherwise only happens for the SOAP binding which cannot be done asynchronously).
     349
     350
     351To initiate, create a button or link to go to a URL on the SP of the form: https://sp.example.org/Shibboleth.sso/Logout
     352
     353The SLO would use an asynchronous message to the IdP and the flow would end at the IdP Logout page.  The user would be returned to the return URL only if the SLO is done in synchronous mode and the flow returns back to the SP.  To set the return URL, pass it in the return parameter as a query string to the Logout initiator - e.g.: https://sp.example.org/Shibboleth.sso/Logout?return=https://sp.example.org/logout-completed.html