Commit 0e3fd919 authored by Giusti Matteo's avatar Giusti Matteo
Browse files

Update Read me.txt, shibboleth/Dockerfile, shibboleth/Description.txt,...

Update Read me.txt, shibboleth/Dockerfile, shibboleth/Description.txt, shibboleth/cfg/default-ssl.conf, shibboleth/cfg/index.php, shibboleth/cfg/shibboleth2.xml, shibboleth/cfg/start.sh, simplesamlphp/Description.txt, simplesamlphp/Dockerfile, simplesamlphp/cfg/authsources.php, simplesamlphp/cfg/config.php, simplesamlphp/cfg/default-ssl.conf, simplesamlphp/cfg/saml20-idp-hosted.php, simplesamlphp/cfg/saml20-sp-remote.php files
parents
The idp and sp are both configured to look for each other at 192.168.0.50 so the host machine needs to have this ip
is there a solution for this ?
It is important to build and run the IdP first, since the sp will download files from it during the building process.
run commands i used after building:
docker run -t -d -p 443:443 --name simplesamlContainer simplesaml:1.5
docker run -t -d -p 9999:443 --name shibContainer shib:1.5
Description of config changes in files that are to copied over
default-ssl.conf - enable ssl and add the sesstest site with shibboleth
index.php - the test site, should have done it with touch & cat
start.sh to be able to run shibboleth and apache2 in one docker
shibboleth2.xml changes:
shib entity id https://192.168.0.50/shibboleth
sso entity id https://192.168.0.50/simplesaml/saml2/idp/metadata.php
certificate files (CredentialResolver)
metadata provider metadata/idp.xml (wich gets downloaded with wget from the idp)
\ No newline at end of file
FROM debian
RUN apt update -y
RUN apt upgrade -y
RUN apt install apache2 -y
RUN apt install apache2 libapache2-mod-php -y
RUN apt install wget -y
RUN apt install openssl -y
RUN apt install php-curl php-xml ntp curl -y
#apache2 setup
RUN mkdir -p /var/lock/apache2
RUN mkdir -p /var/run/apache2
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_PID_FILE /var/run/apache2.pid
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_LOG_DIR /var/log/apache2
ENV LANG C
## We need ssl to get this going, i will use a self signed certificate.
RUN openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -keyout /etc/ssl/private/self.key -out /etc/ssl/certs/self.crt -subj '/CN=localhost/O=INCUBATOR./C=HU' -verbose
RUN ls /etc/ssl/certs | grep self
RUN ls /etc/ssl/private | grep self
RUN rm /etc/apache2/sites-available/default-ssl.conf
#May need to stop service before removing
COPY cfg/default-ssl.conf /etc/apache2/sites-available
RUN chown www-data:www-data /etc/ssl/private/self.key
RUN chown www-data:www-data /etc/ssl/certs/self.crt
RUN a2enmod ssl
RUN a2enmod headers
RUN a2ensite default-ssl
#site for sesstest
RUN mkdir /var/www/html/sesstest
COPY cfg/index.php /var/www/html/sesstest
#RUN /etc/init.d/apache2 reload
#get shib
RUN curl --fail --remote-name https://pkg.switch.ch/switchaai/debian/dists/buster/main/binary-all/misc/switchaai-apt-source_1.0.0_all.deb
RUN apt update -y
RUN apt install ./switchaai-apt-source_1.0.0_all.deb -y
RUN apt update -y
RUN apt install --install-recommends shibboleth -y
#conf shib
RUN openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -keyout /etc/shibboleth/sp-key.pem -out /etc/shibboleth/sp-cert.crt -subj '/CN=localhost/O=INCUBATOR./C=HU' -verbose
RUN chown _shibd /etc/shibboleth/sp-key.pem
RUN chown _shibd /etc/shibboleth/sp-cert.crt
RUN mkdir /etc/shibboleth/metadata
RUN wget -P /etc/shibboleth/metadata --no-check-certificate https://192.168.0.50/simplesaml/saml2/idp/metadata.php
RUN mv /etc/shibboleth/metadata/metadata.php /etc/shibboleth/metadata/idp.xml
COPY cfg/shibboleth2.xml /etc/shibboleth
#RUN /etc/init.d/shibd restart
COPY cfg/start.sh /root
RUN chmod +x /root/start.sh
CMD ["/root/start.sh","-D","FOREGROUND"]
EXPOSE 80 443
\ No newline at end of file
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/sesstest>
AuthType shibboleth
ShibRequestSetting requireSession 1
require valid-user
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/ssl/certs/self.crt
SSLCertificateKeyFile /etc/ssl/private/self.key
# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convinience.
#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt
# Certificate Authority (CA):
# Set the CA certificate verification path where to find CA
# certificates for client authentication or alternatively one
# huge file containing all of them (file must be PEM encoded)
# Note: Inside SSLCACertificatePath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCACertificatePath /etc/ssl/certs/
#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt
# Certificate Revocation Lists (CRL):
# Set the CA revocation path where to find CA CRLs for client
# authentication or alternatively one huge file containing all
# of them (file must be PEM encoded)
# Note: Inside SSLCARevocationPath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCARevocationPath /etc/apache2/ssl.crl/
#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl
# Client Authentication (Type):
# Client certificate verification type and depth. Types are
# none, optional, require and optional_no_ca. Depth is a
# number which specifies how deeply to verify the certificate
# issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth 10
# SSL Engine Options:
# Set various options for the SSL engine.
# o FakeBasicAuth:
# Translate the client X.509 into a Basic Authorisation. This means that
# the standard Auth/DBMAuth methods can be used for access control. The
# user name is the `one line' version of the client's X.509 certificate.
# Note that no password is obtained from the user. Every entry in the user
# file needs this password: `xxj31ZMTZzkVA'.
# o ExportCertData:
# This exports two additional environment variables: SSL_CLIENT_CERT and
# SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
# server (always existing) and the client (only existing when client
# authentication is used). This can be used to import the certificates
# into CGI scripts.
# o StdEnvVars:
# This exports the standard SSL/TLS related `SSL_*' environment variables.
# Per default this exportation is switched off for performance reasons,
# because the extraction step is an expensive operation and is usually
# useless for serving static content. So one usually enables the
# exportation for CGI and SSI requests only.
# o OptRenegotiate:
# This enables optimized SSL connection renegotiation handling when SSL
# directives are used in per-directory context.
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
# SSL Protocol Adjustments:
# The safe and default but still SSL/TLS standard compliant shutdown
# approach is that mod_ssl sends the close notify alert but doesn't wait for
# the close notify alert from client. When you need a different shutdown
# approach you can use one of the following variables:
# o ssl-unclean-shutdown:
# This forces an unclean shutdown when the connection is closed, i.e. no
# SSL close notify alert is send or allowed to received. This violates
# the SSL/TLS standard but is needed for some brain-dead browsers. Use
# this when you receive I/O errors because of the standard approach where
# mod_ssl sends the close notify alert.
# o ssl-accurate-shutdown:
# This forces an accurate shutdown when the connection is closed, i.e. a
# SSL close notify alert is send and mod_ssl waits for the close notify
# alert of the client. This is 100% SSL/TLS standard compliant, but in
# practice often causes hanging connections with brain-dead browsers. Use
# this only for browsers where you know that their SSL implementation
# works correctly.
# Notice: Most problems of broken clients are also related to the HTTP
# keep-alive facility, so you usually additionally want to disable
# keep-alive for those clients, too. Use variable "nokeepalive" for this.
# Similarly, one has to force some clients to use HTTP/1.0 to workaround
# their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
# "force-response-1.0" for this.
# BrowserMatch "MSIE [2-6]" \
# nokeepalive ssl-unclean-shutdown \
# downgrade-1.0 force-response-1.0
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<?php
phpinfo();
?>
<SPConfig xmlns="urn:mace:shibboleth:3.0:native:sp:config"
xmlns:conf="urn:mace:shibboleth:3.0:native:sp:config"
clockSkew="180">
<OutOfProcess tranLogFormat="%u|%s|%IDP|%i|%ac|%t|%attr|%n|%b|%E|%S|%SS|%L|%UA|%a" />
<!--
By default, in-memory StorageService, ReplayCache, ArtifactMap, and SessionCache
are used. See example-shibboleth2.xml for samples of explicitly configuring them.
-->
<!-- The ApplicationDefaults element is where most of Shibboleth's SAML bits are defined. -->
<ApplicationDefaults entityID="https://192.168.0.50/shibboleth"
REMOTE_USER="eppn subject-id pairwise-id persistent-id"
cipherSuites="DEFAULT:!EXP:!LOW:!aNULL:!eNULL:!DES:!IDEA:!SEED:!RC4:!3DES:!kRSA:!SSLv2:!SSLv3:!TLSv1:!TLSv1.1">
<!--
Controls session lifetimes, address checks, cookie handling, and the protocol handlers.
Each Application has an effectively unique handlerURL, which defaults to "/Shibboleth.sso"
and should be a relative path, with the SP computing the full value based on the virtual
host. Use of TLS is now assumed because browsers are enforcing it due to SameSite
restrictions. Note that while we default checkAddress to "false", this makes an assertion
stolen in transit easier for attackers to misuse.
-->
<Sessions lifetime="28800" timeout="3600" relayState="ss:mem"
checkAddress="false" handlerSSL="true" cookieProps="https"
redirectLimit="exact">
<!--
Configures SSO for a default IdP. To properly allow for >1 IdP, remove
entityID property and adjust discoveryURL to point to discovery service.
You can also override entityID on /Login query string, or in RequestMap/htaccess.
-->
<SSO entityID="https://192.168.0.50/simplesaml/saml2/idp/metadata.php"
discoveryProtocol="SAMLDS" discoveryURL="https://ds.example.org/DS/WAYF">
SAML2
</SSO>
<!-- SAML and local-only logout. -->
<Logout>SAML2 Local</Logout>
<!-- Administrative logout. -->
<LogoutInitiator type="Admin" Location="/Logout/Admin" acl="127.0.0.1 ::1" />
<!-- Extension service that generates "approximate" metadata based on SP configuration. -->
<Handler type="MetadataGenerator" Location="/Metadata" signing="false"/>
<!-- Status reporting service. -->
<Handler type="Status" Location="/Status" acl="127.0.0.1 ::1"/>
<!-- Session diagnostic service. -->
<Handler type="Session" Location="/Session" showAttributeValues="false"/>
<!-- JSON feed of discovery information. -->
<Handler type="DiscoveryFeed" Location="/DiscoFeed"/>
</Sessions>
<!--
Allows overriding of error template information/filenames. You can
also add your own attributes with values that can be plugged into the
templates, e.g., helpLocation below.
-->
<Errors supportContact="root@localhost"
helpLocation="/about.html"
styleSheet="/shibboleth-sp/main.css"/>
<!-- Example of locally maintained metadata. -->
<MetadataProvider type="XML" validate="true" path="metadata/idp.xml"/>
<!-- Example of remotely supplied batch of signed metadata. -->
<!--
<MetadataProvider type="XML" validate="true"
url="http://federation.org/federation-metadata.xml"
backingFilePath="federation-metadata.xml" maxRefreshDelay="7200">
<MetadataFilter type="RequireValidUntil" maxValidityInterval="2419200"/>
<MetadataFilter type="Signature" certificate="fedsigner.pem" verifyBackup="false"/>
<DiscoveryFilter type="Blacklist" matcher="EntityAttributes" trimTags="true"
attributeName="http://macedir.org/entity-category"
attributeNameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
attributeValue="http://refeds.org/category/hide-from-discovery" />
</MetadataProvider>
-->
<!-- Example of remotely supplied "on-demand" signed metadata. -->
<!--
<MetadataProvider type="MDQ" validate="true" cacheDirectory="mdq"
baseUrl="http://mdq.federation.org" ignoreTransport="true">
<MetadataFilter type="RequireValidUntil" maxValidityInterval="2419200"/>
<MetadataFilter type="Signature" certificate="mdqsigner.pem" />
</MetadataProvider>
-->
<!-- Map to extract attributes from SAML assertions. -->
<AttributeExtractor type="XML" validate="true" reloadChanges="false" path="attribute-map.xml"/>
<!-- Default filtering policy for recognized attributes, lets other data pass. -->
<AttributeFilter type="XML" validate="true" path="attribute-policy.xml"/>
<!-- Simple file-based resolvers for separate signing/encryption keys. -->
<CredentialResolver type="File" use="signing"
key="sp-key.pem" certificate="sp-cert.crt"/>
<CredentialResolver type="File" use="encryption"
key="sp-key.pem" certificate="sp-cert.crt"/>
</ApplicationDefaults>
<!-- Policies that determine how to process and authenticate runtime messages. -->
<SecurityPolicyProvider type="XML" validate="true" path="security-policy.xml"/>
<!-- Low-level configuration about protocols and bindings available for use. -->
<ProtocolProvider type="XML" validate="true" reloadChanges="false" path="protocols.xml"/>
</SPConfig>
\ No newline at end of file
#!/bin/bash
# Start the first process
/etc/init.d/apache2 start -D
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start my_first_process: $status"
exit $status
fi
sleep 5
# Start the second process
/etc/init.d/shibd start -D
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start my_second_process: $status"
exit $status
fi
# Naive check runs checks once a minute to see if either of the processes exited.
# This illustrates part of the heavy lifting you need to do if you want to run
# more than one service in a container. The container exits with an error
# if it detects that either of the processes has exited.
# Otherwise it loops forever, waking up every 60 seconds
while sleep 60; do
ps aux |grep apache2 |grep -q -v grep
PROCESS_1_STATUS=$?
ps aux |grep shibd |grep -q -v grep
PROCESS_2_STATUS=$?
# If the greps above find anything, they exit with 0 status
# If they are not both 0, then something is wrong
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit 1
fi
done
\ No newline at end of file
Description of config changes in files that are to copied over
authsources.php - enabled the block called example-userpass
default-ssl.conf - enable ssl and add the simplesamlphp site
config.php - Simplesaml config changed:
baseurlpath to https://192.168.0.50/simplesaml/
auth.adminpassword to dummypw
secretsalt to dummysecretsalt
timezone to Europe/budapest
enabled exampleauth
enabled saml20-idp
saml20-idp-hosted.php added certificate filenames, enabled attribute conversion (attributes.NameFormat)
saml20-sp-remote.php Added the parsed metadata of shibboleth to the end of it
FROM debian
RUN apt update -y
RUN apt upgrade -y
RUN apt install apache2 -y
RUN apt install apache2 libapache2-mod-php -y
RUN apt install wget -y
RUN apt install openssl -y
#apache2 setup
RUN mkdir -p /var/lock/apache2
RUN mkdir -p /var/run/apache2
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_PID_FILE /var/run/apache2.pid
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_LOG_DIR /var/log/apache2
ENV LANG C
## We need ssl to get this going, i will use a self signed certificate.
RUN openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -keyout /etc/ssl/private/self.key -out /etc/ssl/certs/self.crt -su$
RUN ls /etc/ssl/certs | grep self
RUN ls /etc/ssl/private | grep self
RUN rm /etc/apache2/sites-available/default-ssl.conf
#May need to stop service before removing
COPY cfg/default-ssl.conf /etc/apache2/sites-available
RUN chown www-data:www-data /etc/ssl/private/self.key
RUN chown www-data:www-data /etc/ssl/certs/self.crt
RUN a2enmod ssl
RUN a2enmod headers
RUN a2ensite default-ssl
#RUN /etc/init.d/apache2 reload
#getting simplSAML
RUN wget https://simplesamlphp.org/download?latest
RUN tar xzf download?latest
RUN mv simplesamlphp* /var/simplesamlphp
#dependencies
RUN apt install php-curl php-xml -y
#config
RUN rm /var/simplesamlphp/config/config.php
RUN rm /var/simplesamlphp/config/authsources.php
COPY cfg/config.php /var/simplesamlphp/config
COPY cfg/authsources.php /var/simplesamlphp/config
#RUN /etc/init.d/apache2 reload
#RUN cd /var/simplesamlphp/cert
RUN openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -keyout /var/simplesamlphp/cert/idp.pem -out /var/simplesamlphp/ce$
RUN chown www-data /var/simplesamlphp/cert/idp.pem
RUN chown www-data /var/simplesamlphp/cert/idp.crt
#Ready metadata:
#RUN rm/var/simplesamlphp/metadata/saml20-idp-hosted.php
#RUN rm/var/simplesamlphp/metadata/saml20-sp-remote.php
COPY cfg/saml20-idp-hosted.php /var/simplesamlphp/metadata
COPY cfg/saml20-sp-remote.php /var/simplesamlphp/metadata
CMD ["/usr/sbin/apache2","-D","FOREGROUND"]
EXPOSE 80 443
\ No newline at end of file
<?php
$config = [
/*
* When multiple authentication sources are defined, you can specify one to use by default
* in order to authenticate users. In order to do that, you just need to name it "default"
* here. That authentication source will be used by default then when a user reaches the
* SimpleSAMLphp installation from the web browser, without passing through the API.
*
* If you already have named your auth source with a different name, you don't need to change
* it in order to use it as a default. Just create an alias by the end of this file:
*
* $config['default'] = &$config['your_auth_source'];
*/
// This is a authentication source which handles admin authentication.
'admin' => [
// The default is to use core:AdminPassword, but it can be replaced with
// any authentication source.
'core:AdminPassword',
],
// An authentication source which can authenticate against both SAML 2.0
// and Shibboleth 1.3 IdPs.
'default-sp' => [
'saml:SP',
// The entity ID of this SP.
// Can be NULL/unset, in which case an entity ID is generated based on the metadata URL.
'entityID' => null,
// The entity ID of the IdP this SP should contact.
// Can be NULL/unset, in which case the user will be shown a list of available IdPs.
'idp' => null,
// The URL to the discovery service.
// Can be NULL/unset, in which case a builtin discovery service will be used.
'discoURL' => null,
/*
* The attributes parameter must contain an array of desired attributes by the SP.
* The attributes can be expressed as an array of names or as an associative array
* in the form of 'friendlyName' => 'name'. This feature requires 'name' to be set.
* The metadata will then be created as follows:
* <md:RequestedAttribute FriendlyName="friendlyName" Name="name" />
*/
/*
'name' => [
'en' => 'A service',
'no' => 'En tjeneste',
],
'attributes' => [
'attrname' => 'urn:oid:x.x.x.x',
],
'attributes.required' => [
'urn:oid:x.x.x.x',
],
*/
],
/*
'example-sql' => [
'sqlauth:SQL',
'dsn' => 'pgsql:host=sql.example.org;port=5432;dbname=simplesaml',
'username' => 'simplesaml',
'password' => 'secretpassword',
'query' => 'SELECT uid, givenName, email, eduPersonPrincipalName FROM users WHERE uid = :username ' .
'AND password = SHA2(CONCAT((SELECT salt FROM users WHERE uid = :username), :password), 256);',
],
*/
/*
'example-static' => [
'exampleauth:StaticSource',
'uid' => ['testuser'],
'eduPersonAffiliation' => ['member', 'employee'],
'cn' => ['Test User'],
],
*/
'example-userpass' => [
'exampleauth:UserPass',
// Give the user an option to save their username for future login attempts
// And when enabled, what should the default be, to save the username or not
//'remember.username.enabled' => false,
//'remember.username.checked' => false,
'student:studentpass' => [
'uid' => ['test'],
'eduPersonAffiliation' => ['member', 'student'],
],
'employee:employeepass' => [
'uid' => ['employee'],
'eduPersonAffiliation' => ['member', 'employee'],
],
],
/*
'crypto-hash' => [
'authcrypt:Hash',
// hashed version of 'verysecret', made with bin/pwgen.php
'professor:{SSHA256}P6FDTEEIY2EnER9a6P2GwHhI5JDrwBgjQ913oVQjBngmCtrNBUMowA==' => [
'uid' => ['prof_a'],
'eduPersonAffiliation' => ['member', 'employee', 'board'],
],
],
*/
/*
'htpasswd' => [
'authcrypt:Htpasswd',
'htpasswd_file' => '/var/www/foo.edu/legacy_app/.htpasswd',
'static_attributes' => [
'eduPersonAffiliation' => ['member', 'employee'],
'Organization' => ['University of Foo'],
],
],
*/
/*
// This authentication source serves as an example of integration with an
// external authentication engine. Take a look at the comment in the beginning
// of modules/exampleauth/lib/Auth/Source/External.php for a description of
// how to adjust it to your own site.
'example-external' => [
'exampleauth:External',
],
*/
/*
'yubikey' => [
'authYubiKey:YubiKey',
'id' => '000',
// 'key' => '012345678',