From 1894a029655786051e9f51dc47f9533f963a7903 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Fri, 12 Oct 2018 16:15:59 -0400 Subject: [PATCH 01/16] initial commit --- Dockerfile | 37 +-- container_files/etc/httpd/conf.d/ssl.conf | 6 - .../etc/httpd/conf.modules.d/00-shib.conf | 1 - .../etc/shibboleth/attribute-map.xml | 32 --- container_files/httpd/ssl.conf | 217 ++++++++++++++++++ .../{etc => }/shibboleth/inc-md-cert.pem | 0 .../{bin => system}/httpd-shib-foreground | 0 .../{bin => system}/shibboleth_keygen.sh | 0 8 files changed, 239 insertions(+), 54 deletions(-) delete mode 100644 container_files/etc/httpd/conf.d/ssl.conf delete mode 100644 container_files/etc/httpd/conf.modules.d/00-shib.conf delete mode 100644 container_files/etc/shibboleth/attribute-map.xml create mode 100644 container_files/httpd/ssl.conf rename container_files/{etc => }/shibboleth/inc-md-cert.pem (100%) rename container_files/{bin => system}/httpd-shib-foreground (100%) rename container_files/{bin => system}/shibboleth_keygen.sh (100%) diff --git a/Dockerfile b/Dockerfile index 3d6a5cf..8f4110b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM tier/centos7base +FROM centos:centos7 # Define args and set a default value ARG maintainer=tier ARG imagename=shibboleth_sp -ARG version=2.6.1 +ARG version=3.0.2 MAINTAINER $maintainer LABEL Vendor="Internet2" @@ -14,31 +14,38 @@ LABEL Version=$version LABEL Build docker build --rm --tag $maintainer/$imagename . -# Add starters and installers -ADD ./container_files /opt +ADD ./container_files/bin/httpd-shib-foreground /usr/local/bin/ +ADD ./container_files/bin/shibboleth_keygen.sh /usr/local/bin/ +ADD ./container_files/etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ + + +RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime \ + && echo "NETWORKING=yes" > /etc/sysconfig/network + +RUN rm -fr /var/cache/yum/* && yum clean all && yum -y install --setopt=tsflags=nodocs epel-release && yum -y update && \ + yum -y install net-tools wget curl tar unzip mlocate logrotate strace telnet man vim rsyslog cron httpd mod_ssl dos2unix && \ + yum clean all RUN curl -o /etc/yum.repos.d/security:shibboleth.repo \ http://download.opensuse.org/repositories/security://shibboleth/CentOS_7/security:shibboleth.repo \ - && yum -y update \ - && yum -y install \ - httpd \ - mod_ssl \ - shibboleth.x86_64 \ - dos2unix \ + && yum -y install shibboleth.x86_64 \ && yum clean all \ && rm /etc/httpd/conf.d/autoindex.conf \ - && rm /etc/httpd/conf.d/ssl.conf \ && rm /etc/httpd/conf.d/userdir.conf \ && rm /etc/httpd/conf.d/welcome.conf \ - && chmod +x /opt/bin/httpd-shib-foreground \ - && chmod +x /opt/bin/shibboleth_keygen.sh + && chmod +x /usr/local/bin/httpd-shib-foreground \ + && chmod +x /usr/local/bin/shibboleth_keygen.sh # Export this variable so that shibd can find its CURL library RUN LD_LIBRARY_PATH="/opt/shibboleth/lib64" RUN export LD_LIBRARY_PATH -#Script to start service, Added ssl default conf, Added shib module apache -RUN ln -s /opt/bin/httpd-shib-foreground /usr/local/bin && ln -s /opt/etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf && ln -s /opt/etc/httpd/conf.modules.d/00-shib.conf /etc/httpd/conf.modules.d/00-shib.conf && ln -s /usr/lib64/shibboleth/mod_shib_24.so /etc/httpd/modules/mod_shib_24.so +# fix shibd.logger, other?.logger + +# fix httpd logging to tier format + EXPOSE 80 443 CMD ["httpd-shib-foreground"] + + diff --git a/container_files/etc/httpd/conf.d/ssl.conf b/container_files/etc/httpd/conf.d/ssl.conf deleted file mode 100644 index ccc067c..0000000 --- a/container_files/etc/httpd/conf.d/ssl.conf +++ /dev/null @@ -1,6 +0,0 @@ -SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog -SSLSessionCache shmcb:/run/httpd/sslcache(512000) -SSLSessionCacheTimeout 300 -SSLRandomSeed startup file:/dev/urandom 256 -SSLRandomSeed connect builtin -SSLCryptoDevice builtin diff --git a/container_files/etc/httpd/conf.modules.d/00-shib.conf b/container_files/etc/httpd/conf.modules.d/00-shib.conf deleted file mode 100644 index 0e5c7b2..0000000 --- a/container_files/etc/httpd/conf.modules.d/00-shib.conf +++ /dev/null @@ -1 +0,0 @@ -LoadModule mod_shib /usr/lib64/shibboleth/mod_shib_24.so diff --git a/container_files/etc/shibboleth/attribute-map.xml b/container_files/etc/shibboleth/attribute-map.xml deleted file mode 100644 index 12c4019..0000000 --- a/container_files/etc/shibboleth/attribute-map.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/container_files/httpd/ssl.conf b/container_files/httpd/ssl.conf new file mode 100644 index 0000000..3eec310 --- /dev/null +++ b/container_files/httpd/ssl.conf @@ -0,0 +1,217 @@ +# +# When we also provide SSL we have to listen to the +# the HTTPS port in addition. +# +Listen 443 https + +## +## SSL Global Context +## +## All SSL configuration in this context applies both to +## the main server and all SSL-enabled virtual hosts. +## + +# Pass Phrase Dialog: +# Configure the pass phrase gathering process. +# The filtering dialog program (`builtin' is a internal +# terminal dialog) has to provide the pass phrase on stdout. +SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog + +# Inter-Process Session Cache: +# Configure the SSL Session Cache: First the mechanism +# to use and second the expiring timeout (in seconds). +SSLSessionCache shmcb:/run/httpd/sslcache(512000) +SSLSessionCacheTimeout 300 + +# Pseudo Random Number Generator (PRNG): +# Configure one or more sources to seed the PRNG of the +# SSL library. The seed data should be of good random quality. +# WARNING! On some platforms /dev/random blocks if not enough entropy +# is available. This means you then cannot use the /dev/random device +# because it would lead to very long connection times (as long as +# it requires to make more entropy available). But usually those +# platforms additionally provide a /dev/urandom device which doesn't +# block. So, if available, use this one instead. Read the mod_ssl User +# Manual for more details. +SSLRandomSeed startup file:/dev/urandom 256 +SSLRandomSeed connect builtin +#SSLRandomSeed startup file:/dev/random 512 +#SSLRandomSeed connect file:/dev/random 512 +#SSLRandomSeed connect file:/dev/urandom 512 + +# +# Use "SSLCryptoDevice" to enable any supported hardware +# accelerators. Use "openssl engine -v" to list supported +# engine names. NOTE: If you enable an accelerator and the +# server does not start, consult the error logs and ensure +# your accelerator is functioning properly. +# +SSLCryptoDevice builtin +#SSLCryptoDevice ubsec + +## +## SSL Virtual Host Context +## + + + +# General setup for the virtual host, inherited from global configuration +#DocumentRoot "/var/www/html" +#ServerName www.example.com:443 + +# Use separate log files for the SSL virtual host; note that LogLevel +# is not inherited from httpd.conf. +ErrorLog logs/ssl_error_log +TransferLog logs/ssl_access_log +LogLevel warn + +# SSL Engine Switch: +# Enable/Disable SSL for this virtual host. +SSLEngine on + +# SSL Protocol support: +# List the enable protocol levels with which clients will be able to +# connect. Disable SSLv2 access by default: +SSLProtocol all -SSLv2 -SSLv3 + +# SSL Cipher Suite: +# List the ciphers that the client is permitted to negotiate. +# See the mod_ssl documentation for a complete list. +SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA + +# Speed-optimized SSL Cipher configuration: +# If speed is your main concern (on busy HTTPS servers e.g.), +# you might want to force clients to specific, performance +# optimized ciphers. In this case, prepend those ciphers +# to the SSLCipherSuite list, and enable SSLHonorCipherOrder. +# Caveat: by giving precedence to RC4-SHA and AES128-SHA +# (as in the example below), most connections will no longer +# have perfect forward secrecy - if the server's key is +# compromised, captures of past or future traffic must be +# considered compromised, too. +#SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:MEDIUM:!aNULL:!MD5 +#SSLHonorCipherOrder on + +# Server Certificate: +# Point SSLCertificateFile at a PEM encoded certificate. If +# the certificate is encrypted, then you will be prompted for a +# pass phrase. Note that a kill -HUP will prompt again. A new +# certificate can be generated using the genkey(1) command. +SSLCertificateFile /etc/pki/tls/certs/localhost.crt + +# Server Private Key: +# If the key is not combined with the certificate, use this +# directive to point at the key file. Keep in mind that if +# you've both a RSA and a DSA private key you can configure +# both in parallel (to also allow the use of DSA ciphers, etc.) +SSLCertificateKeyFile /etc/pki/tls/private/localhost.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/pki/tls/certs/server-chain.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) +#SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt + +# 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 + +# Access Control: +# With SSLRequire you can do per-directory access control based +# on arbitrary complex boolean expressions containing server +# variable checks and other lookup directives. The syntax is a +# mixture between C and Perl. See the mod_ssl documentation +# for more details. +# +#SSLRequire ( %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \ +# and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \ +# and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \ +# and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \ +# and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20 ) \ +# or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/ +# + +# 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 StrictRequire: +# This denies access when "SSLRequireSSL" or "SSLRequire" applied even +# under a "Satisfy any" situation, i.e. when it applies access is denied +# and no other module can change it. +# o OptRenegotiate: +# This enables optimized SSL connection renegotiation handling when SSL +# directives are used in per-directory context. +#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + +# 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-5]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + +# Per-Server Logging: +# The home of a custom SSL log file. Use this when you want a +# compact non-error SSL logfile on a virtual host basis. +CustomLog logs/ssl_request_log \ + "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" + + + diff --git a/container_files/etc/shibboleth/inc-md-cert.pem b/container_files/shibboleth/inc-md-cert.pem similarity index 100% rename from container_files/etc/shibboleth/inc-md-cert.pem rename to container_files/shibboleth/inc-md-cert.pem diff --git a/container_files/bin/httpd-shib-foreground b/container_files/system/httpd-shib-foreground similarity index 100% rename from container_files/bin/httpd-shib-foreground rename to container_files/system/httpd-shib-foreground diff --git a/container_files/bin/shibboleth_keygen.sh b/container_files/system/shibboleth_keygen.sh similarity index 100% rename from container_files/bin/shibboleth_keygen.sh rename to container_files/system/shibboleth_keygen.sh From 4d8885c5cf25b262d9ec72c44582384170268f93 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Fri, 12 Oct 2018 22:15:15 +0000 Subject: [PATCH 02/16] updates --- BINSCRIPTS.md | 41 ---------------- Dockerfile | 28 +++++++---- README.md | 1 - bin/ci-run.sh | 3 +- bin/ci-stop.sh | 1 + common.bash | 2 +- container_files/httpd/index.html | 3 ++ container_files/shibboleth/native.logger | 40 ++++++++++++++++ container_files/shibboleth/shibd.logger | 60 ++++++++++++++++++++++++ install.sh | 13 ----- tests/image.bats | 11 +++-- tests/running.bats | 3 +- 12 files changed, 134 insertions(+), 72 deletions(-) delete mode 100644 BINSCRIPTS.md create mode 100644 container_files/httpd/index.html create mode 100644 container_files/shibboleth/native.logger create mode 100644 container_files/shibboleth/shibd.logger delete mode 100755 install.sh diff --git a/BINSCRIPTS.md b/BINSCRIPTS.md deleted file mode 100644 index f5949ba..0000000 --- a/BINSCRIPTS.md +++ /dev/null @@ -1,41 +0,0 @@ -# util - -This repository is intended to be downloaded into a container repository during development for convenience purposes. Since the major mechanisms of developing to the Docker container construction lifecycle are identical across container images, this repository allows for consistency and additional ease of use across all container images. - -## Install - -If you are reading this file in BINSCRIPTS.md, your container project is likely to be util-enabled. - -To use these scripts yourself, issue this command: - -``` -curl "https://github.internet2.edu/raw/docker/util/master/bin/install.sh?token=AAAAETsVKUnOEAMM8TvUUZccPYi13wsnks5Xq46jwA%3D%3D" | bash -``` - -### common.bash - -The installation process will create a common.bash file. This file should be the central, canonical authority for management of environment variables. While a subprocess may override them, the files in common.bash should be treated as authoritative defaults. Processes (e.g. `docker build`, `bats`, inside `Jenkinsfile`) can read this file and process the results therein. - -You should edit this file to change the image name, and add any other helpful environment variables. - -### Jenkinsfile - -This will also install a Jenkinsfile to your repository, if it doesn't have one. This will ensure that your Jenkins pipeline can leverage these scripts in the way intended. Ensuring the commands that you issue on your laptop match the commands issued by the build pipeline is critical to ensure predictable, reliable results. - -## Use - - -### Building - -#### build.sh -`bin/build.sh ` -#### destroy.sh -#### rebuild.sh - -### Running -### rerun.sh -### run.sh - - -### Testing -#### test.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8f4110b..44fce78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,6 @@ LABEL Version=$version LABEL Build docker build --rm --tag $maintainer/$imagename . -ADD ./container_files/bin/httpd-shib-foreground /usr/local/bin/ -ADD ./container_files/bin/shibboleth_keygen.sh /usr/local/bin/ -ADD ./container_files/etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ - - RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime \ && echo "NETWORKING=yes" > /etc/sysconfig/network @@ -32,17 +27,32 @@ RUN curl -o /etc/yum.repos.d/security:shibboleth.repo \ && yum clean all \ && rm /etc/httpd/conf.d/autoindex.conf \ && rm /etc/httpd/conf.d/userdir.conf \ - && rm /etc/httpd/conf.d/welcome.conf \ - && chmod +x /usr/local/bin/httpd-shib-foreground \ - && chmod +x /usr/local/bin/shibboleth_keygen.sh + && rm /etc/httpd/conf.d/welcome.conf # Export this variable so that shibd can find its CURL library RUN LD_LIBRARY_PATH="/opt/shibboleth/lib64" RUN export LD_LIBRARY_PATH -# fix shibd.logger, other?.logger +ADD ./container_files/system/httpd-shib-foreground /usr/local/bin/ +ADD ./container_files/system/shibboleth_keygen.sh /usr/local/bin/ +ADD ./container_files/httpd/ssl.conf /etc/httpd/conf.d/ +ADD ./container_files/shibboleth/* /etc/shibboleth/ + +RUN chmod +x /usr/local/bin/httpd-shib-foreground \ + && chmod +x /usr/local/bin/shibboleth_keygen.sh # fix httpd logging to tier format +RUN sed -i 's/LogFormat "/LogFormat "httpd;access_log;%{ENV}e;%{USERTOKEN}e;/g' /etc/httpd/conf/httpd.conf \ + && echo -e "\nErrorLogFormat \"httpd;error_log;%{ENV}e;%{USERTOKEN}e;[%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% ,\ referer\ %{Referer}i\"" >> /etc/httpd/conf/httpd.conf \ + && sed -i 's/CustomLog "logs\/access_log"/CustomLog "\/tmp\/logpipe"/g' /etc/httpd/conf/httpd.conf \ + && sed -i 's/ErrorLog "logs\/error_log"/ErrorLog "\/tmp\/logpipe"/g' /etc/httpd/conf/httpd.conf \ + && echo -e "\nPassEnv ENV" >> /etc/httpd/conf/httpd.conf \ + && echo -e "\nPassEnv USERTOKEN" >> /etc/httpd/conf/httpd.conf \ + && sed -i '/UseCanonicalName/c\UseCanonicalName On' /etc/httpd/conf/httpd.conf + +# add a basic page to shibb's default protected directory +RUN mkdir -p /var/www/html/secure/ +ADD container_files/httpd/index.html /var/www/html/secure/ EXPOSE 80 443 diff --git a/README.md b/README.md index 3f96763..4e686a3 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,4 @@ [![Build Status](https://jenkins.testbed.tier.internet2.edu/buildStatus/icon?job=docker/shib-sp/master)](https://jenkins.testbed.tier.internet2.edu/job/docker/shib-sp/master) -This image is the parent of COmanage and Grouper containers, as it contains the OpenSUSE repositories for shibboleth package management, and an apache installation. diff --git a/bin/ci-run.sh b/bin/ci-run.sh index 70761f0..4ef1dc0 100755 --- a/bin/ci-run.sh +++ b/bin/ci-run.sh @@ -3,4 +3,5 @@ # This file will run a container in the background source common.bash . -docker run -d --name=$imagename -p 80:80 -p 443:443 $maintainer/$imagename \ No newline at end of file +docker run -d --name=$imagename -p 80:80 -p 443:443 $maintainer/$imagename + diff --git a/bin/ci-stop.sh b/bin/ci-stop.sh index 54ab019..60c6f27 100755 --- a/bin/ci-stop.sh +++ b/bin/ci-stop.sh @@ -6,3 +6,4 @@ source common.bash . echo "Cleaning up Docker image($maintainer/$imagename)" docker stop $imagename >> /dev/null docker rm $imagename + diff --git a/common.bash b/common.bash index 362ce33..8c19ea3 100644 --- a/common.bash +++ b/common.bash @@ -1,3 +1,3 @@ maintainer="tier" imagename="shibboleth_sp" -version="2.5.1" \ No newline at end of file +version="3.0.2" diff --git a/container_files/httpd/index.html b/container_files/httpd/index.html new file mode 100644 index 0000000..9b3dd7a --- /dev/null +++ b/container_files/httpd/index.html @@ -0,0 +1,3 @@ +
+

This page is protected by the Shibboleth SP.

+ diff --git a/container_files/shibboleth/native.logger b/container_files/shibboleth/native.logger new file mode 100644 index 0000000..1f01974 --- /dev/null +++ b/container_files/shibboleth/native.logger @@ -0,0 +1,40 @@ +# set overall behavior +log4j.rootCategory=INFO, native_log, warn_log + +# fairly verbose for DEBUG, so generally leave at INFO +log4j.category.XMLTooling.XMLObject=INFO +log4j.category.XMLTooling.KeyInfoResolver=INFO +log4j.category.Shibboleth.IPRange=INFO +log4j.category.Shibboleth.PropertySet=INFO + +# raise for low-level tracing of SOAP client HTTP/SSL behavior +log4j.category.XMLTooling.libcurl=INFO + +# useful categories to tune independently: +# +# tracing of SAML messages and security policies +#log4j.category.OpenSAML.MessageDecoder=DEBUG +#log4j.category.OpenSAML.MessageEncoder=DEBUG +#log4j.category.OpenSAML.SecurityPolicyRule=DEBUG +# interprocess message remoting +#log4j.category.Shibboleth.Listener=DEBUG +# mapping of requests to applicationId +#log4j.category.Shibboleth.RequestMapper=DEBUG +# high level session cache operations +#log4j.category.Shibboleth.SessionCache=DEBUG +# persistent storage and caching +#log4j.category.XMLTooling.StorageService=DEBUG + +# define the appender + +log4j.appender.native_log=org.apache.log4j.FileAppender +log4j.appender.native_log.fileName=/tmp/logpipe +log4j.appender.native_log.layout=org.apache.log4j.PatternLayout +log4j.appender.native_log.layout.ConversionPattern=shibd;native.log;${ENV};${USERTOKEN};%d{%Y-%m-%d %H:%M:%S} %p %c %x: %m%n + +log4j.appender.warn_log=org.apache.log4j.FileAppender +log4j.appender.warn_log.fileName=/tmp/logpipe +log4j.appender.warn_log.layout=org.apache.log4j.PatternLayout +log4j.appender.warn_log.layout.ConversionPattern=shibd;native_warn.log;${ENV};${USERTOKEN};%d{%Y-%m-%d %H:%M:%S} %p %c %x: %m%n +log4j.appender.warn_log.threshold=WARN + diff --git a/container_files/shibboleth/shibd.logger b/container_files/shibboleth/shibd.logger new file mode 100644 index 0000000..d3b26cd --- /dev/null +++ b/container_files/shibboleth/shibd.logger @@ -0,0 +1,60 @@ +# set overall behavior +log4j.rootCategory=INFO, shibd_log + +# fairly verbose for DEBUG, so generally leave at INFO +log4j.category.XMLTooling.XMLObject=INFO +log4j.category.XMLTooling.KeyInfoResolver=INFO +log4j.category.Shibboleth.IPRange=INFO +log4j.category.Shibboleth.PropertySet=INFO + +# raise for low-level tracing of SOAP client HTTP/SSL behavior +log4j.category.XMLTooling.libcurl=INFO + +# useful categories to tune independently: +# +# tracing of SAML messages and security policies +#log4j.category.OpenSAML.MessageDecoder=DEBUG +#log4j.category.OpenSAML.MessageEncoder=DEBUG +#log4j.category.OpenSAML.SecurityPolicyRule=DEBUG +#log4j.category.XMLTooling.SOAPClient=DEBUG +# interprocess message remoting +#log4j.category.Shibboleth.Listener=DEBUG +# mapping of requests to applicationId +#log4j.category.Shibboleth.RequestMapper=DEBUG +# high level session cache operations +#log4j.category.Shibboleth.SessionCache=DEBUG +# persistent storage and caching +#log4j.category.XMLTooling.StorageService=DEBUG + +# logs XML being signed or verified if set to DEBUG +log4j.category.XMLTooling.Signature.Debugger=INFO, sig_log +log4j.additivity.XMLTooling.Signature.Debugger=false + +# the tran log blocks the "default" appender(s) at runtime +# Level should be left at INFO for this category +log4j.category.Shibboleth-TRANSACTION=INFO, tran_log +log4j.additivity.Shibboleth-TRANSACTION=false +# uncomment to suppress particular event types +#log4j.category.Shibboleth-TRANSACTION.AuthnRequest=WARN +#log4j.category.Shibboleth-TRANSACTION.Login=WARN +#log4j.category.Shibboleth-TRANSACTION.Logout=WARN + +# define the appenders + +log4j.appender.shibd_log=org.apache.log4j.FileAppender +log4j.appender.shibd_log.fileName=/tmp/logpipe +log4j.appender.shibd_log.maxFileSize=0 +log4j.appender.shibd_log.layout=org.apache.log4j.PatternLayout +log4j.appender.shibd_log.layout.ConversionPattern=shibd;shibd.log;${ENV};${USERTOKEN};%d{%Y-%m-%d %H:%M:%S} %p %c %x: %m%n + +log4j.appender.tran_log=org.apache.log4j.FileAppender +log4j.appender.tran_log.fileName=/tmp/logpipe +log4j.appender.tran_log.maxFileSize=0 +log4j.appender.tran_log.layout=org.apache.log4j.PatternLayout +log4j.appender.tran_log.layout.ConversionPattern=shibd;transaction.log;${ENV};${USERTOKEN};%d{%Y-%m-%d %H:%M:%S} %p %c %x: %m%n + +log4j.appender.sig_log=org.apache.log4j.FileAppender +log4j.appender.sig_log.fileName=/tmp/logpipe +log4j.appender.sig_log.layout=org.apache.log4j.PatternLayout +log4j.appender.sig_log.layout.ConversionPattern=shibd;signature.log;${ENV};${USERTOKEN};%m + diff --git a/install.sh b/install.sh deleted file mode 100755 index ddfd5b0..0000000 --- a/install.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -git clone git@github.internet2.edu:docker/util.git -find util/bin -name "*.sh" -exec sh -c 'echo "$1" | sed "s/util\///" >> .gitignore' -- {} \; -mkdir -p bin -mv util/bin/* bin/. -mv util/README.md BINSCRIPTS.md -if [ ! -f common.bash ]; then - mv util/common.bash.sample common.bash -fi -if [ ! -f Jenkinsfile ]; then - mv util/Jenkinsfile.sample Jenkinsfile -fi -rm -rf util diff --git a/tests/image.bats b/tests/image.bats index 769c4c9..3d9fb5e 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -11,17 +11,18 @@ load ../common } @test "Sample attribute map available" { - docker run -i $maintainer/$imagename find /opt/etc/shibboleth/attribute-map.xml + docker run -i $maintainer/$imagename find /etc/shibboleth/attribute-map.xml } @test "Includes InCommon cert" { - docker run -i $maintainer/$imagename find /opt/etc/shibboleth/inc-md-cert.pem + docker run -i $maintainer/$imagename find /etc/shibboleth/inc-md-cert.pem } @test "Includes Shibboleth keygenerator" { - docker run -i $maintainer/$imagename find /opt/bin/shibboleth_keygen.sh + docker run -i $maintainer/$imagename find /usr/local/bin/shibboleth_keygen.sh } @test "Includes httpd + shibd startup script" { - docker run -i $maintainer/$imagename find /opt/bin/httpd-shib-foreground -} \ No newline at end of file + docker run -i $maintainer/$imagename find /usr/local/bin/httpd-shib-foreground +} + diff --git a/tests/running.bats b/tests/running.bats index 882aaec..781715b 100644 --- a/tests/running.bats +++ b/tests/running.bats @@ -17,4 +17,5 @@ load ../common @test "Exposes running SSO process" { result="$(docker exec -i $imagename curl http://localhost/Shibboleth.sso/Status)" [ "$result" != '' ] -} \ No newline at end of file +} + From fdc9feb688d13b3811673fcd8dbb200fcfe3f758 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Fri, 12 Oct 2018 22:39:37 +0000 Subject: [PATCH 03/16] update readme --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 4e686a3..f5d340d 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,25 @@ [![Build Status](https://jenkins.testbed.tier.internet2.edu/buildStatus/icon?job=docker/shib-sp/master)](https://jenkins.testbed.tier.internet2.edu/job/docker/shib-sp/master) +This is the TIER upstream Shibboleth SP container. + +It is based from CentOS 7 and includes httpd, mod_ssl, and the current shibboleth SP. + +Files you must supply/override in your downstream builds: + +The SP's private key and corresponding certificate (very important!) can be generated in your downstream container like this: + RUN /usr/local/bin/shibboleth_keygen.sh -o /etc/shibboleth -f + ...that command generates/overwrites the following files: + /etc/shibboleth/sp-key.pem + /etc/shibboleth/sp-cert.pem + +/etc/httpd/conf.d/ssl.conf + including: + ServerName fqdn:port + UseCanonicalName On + +/etc/shibboleth/shibboleth2.xml + including: + entityID + From 6a33e72db2e3bd1a87e58b72066005243a71a50d Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Fri, 12 Oct 2018 22:41:06 +0000 Subject: [PATCH 04/16] fix readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f5d340d..c66928e 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,10 @@ Files you must supply/override in your downstream builds: The SP's private key and corresponding certificate (very important!) can be generated in your downstream container like this: RUN /usr/local/bin/shibboleth_keygen.sh -o /etc/shibboleth -f + ...that command generates/overwrites the following files: /etc/shibboleth/sp-key.pem + /etc/shibboleth/sp-cert.pem /etc/httpd/conf.d/ssl.conf From a299c9c24d5701f75785373e53db8d921b59d737 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Sat, 13 Oct 2018 16:27:36 +0000 Subject: [PATCH 05/16] supervisord, beacon --- Dockerfile | 32 +++++++-- README.md | 52 ++++++++------ container_files/system/httpd-shib-foreground | 7 -- container_files/system/sendtierbeacon.sh | 28 ++++++++ container_files/system/setenv.sh | 6 ++ container_files/system/setupcron.sh | 18 +++++ container_files/system/startup.sh | 27 ++++++++ container_files/system/supervisord.conf | 37 ++++++++++ tests/clairscan.sh | 73 ++++++++++++++++++++ tests/image.bats | 3 + 10 files changed, 246 insertions(+), 37 deletions(-) delete mode 100755 container_files/system/httpd-shib-foreground create mode 100755 container_files/system/sendtierbeacon.sh create mode 100755 container_files/system/setenv.sh create mode 100755 container_files/system/setupcron.sh create mode 100755 container_files/system/startup.sh create mode 100644 container_files/system/supervisord.conf create mode 100755 tests/clairscan.sh diff --git a/Dockerfile b/Dockerfile index 44fce78..06810e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,9 +18,10 @@ RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime \ && echo "NETWORKING=yes" > /etc/sysconfig/network RUN rm -fr /var/cache/yum/* && yum clean all && yum -y install --setopt=tsflags=nodocs epel-release && yum -y update && \ - yum -y install net-tools wget curl tar unzip mlocate logrotate strace telnet man vim rsyslog cron httpd mod_ssl dos2unix && \ + yum -y install net-tools wget curl tar unzip mlocate logrotate strace telnet man vim rsyslog cron httpd mod_ssl dos2unix cronie supervisor && \ yum clean all +#install shibboleth, cleanup httpd RUN curl -o /etc/yum.repos.d/security:shibboleth.repo \ http://download.opensuse.org/repositories/security://shibboleth/CentOS_7/security:shibboleth.repo \ && yum -y install shibboleth.x86_64 \ @@ -33,13 +34,10 @@ RUN curl -o /etc/yum.repos.d/security:shibboleth.repo \ RUN LD_LIBRARY_PATH="/opt/shibboleth/lib64" RUN export LD_LIBRARY_PATH -ADD ./container_files/system/httpd-shib-foreground /usr/local/bin/ ADD ./container_files/system/shibboleth_keygen.sh /usr/local/bin/ ADD ./container_files/httpd/ssl.conf /etc/httpd/conf.d/ ADD ./container_files/shibboleth/* /etc/shibboleth/ - -RUN chmod +x /usr/local/bin/httpd-shib-foreground \ - && chmod +x /usr/local/bin/shibboleth_keygen.sh +RUN chmod +x /usr/local/bin/shibboleth_keygen.sh # fix httpd logging to tier format RUN sed -i 's/LogFormat "/LogFormat "httpd;access_log;%{ENV}e;%{USERTOKEN}e;/g' /etc/httpd/conf/httpd.conf \ @@ -51,11 +49,31 @@ RUN sed -i 's/LogFormat "/LogFormat "httpd;access_log;%{ENV}e;%{USERTOKEN}e;/g' && sed -i '/UseCanonicalName/c\UseCanonicalName On' /etc/httpd/conf/httpd.conf # add a basic page to shibb's default protected directory -RUN mkdir -p /var/www/html/secure/ +RUN mkdir -p /var/www/html/secure/; mkdir -p /opt/tier/ ADD container_files/httpd/index.html /var/www/html/secure/ +# setup crond and supervisord +ADD container_files/system/startup.sh /usr/local/bin/ +ADD container_files/system/setupcron.sh /usr/local/bin/ +ADD container_files/system/setenv.sh /opt/tier/ +ADD container_files/system/sendtierbeacon.sh /usr/local/bin/ +ADD container_files/system/supervisord.conf /etc/supervisor/ +RUN mkdir -p /etc/supervisor/conf.d \ + && chmod +x /usr/local/bin/setupcron.sh \ + && chmod +x /usr/local/bin/sendtierbeacon.sh \ +# setup cron + && /usr/local/bin/setupcron.sh + +#set cron to not require a login session +RUN sed -i '/session required pam_loginuid.so/c\#session required pam_loginuid.so' /etc/pam.d/crond + + EXPOSE 80 443 -CMD ["httpd-shib-foreground"] +HEALTHCHECK --interval=1m --timeout=30s \ + CMD curl -k -f https://127.0.0.1:8443/Shibboleth.sso/Status || exit 1 + + +CMD ["/usr/local/bin/startup.sh"] diff --git a/README.md b/README.md index c66928e..3c2eced 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,34 @@ -# shibboleth-sp +# TIER shibboleth-sp [![Build Status](https://jenkins.testbed.tier.internet2.edu/buildStatus/icon?job=docker/shib-sp/master)](https://jenkins.testbed.tier.internet2.edu/job/docker/shib-sp/master) -This is the TIER upstream Shibboleth SP container. - -It is based from CentOS 7 and includes httpd, mod_ssl, and the current shibboleth SP. - -Files you must supply/override in your downstream builds: - -The SP's private key and corresponding certificate (very important!) can be generated in your downstream container like this: - RUN /usr/local/bin/shibboleth_keygen.sh -o /etc/shibboleth -f - - ...that command generates/overwrites the following files: - /etc/shibboleth/sp-key.pem - - /etc/shibboleth/sp-cert.pem - -/etc/httpd/conf.d/ssl.conf - including: - ServerName fqdn:port - UseCanonicalName On - -/etc/shibboleth/shibboleth2.xml - including: - entityID +This is the TIER upstream Shibboleth SP container. + +It is based from CentOS 7 and includes httpd, mod_ssl, and the current shibboleth SP. + +Files you must supply/override in your downstream builds: + +1. The SP's ***private key and corresponding certificate*** (very important!), which can be generated in your downstream container like this: +> RUN /usr/local/bin/shibboleth_keygen.sh -o /etc/shibboleth -f +> +> ...that command generates/overwrites the following files: +> /etc/shibboleth/sp-key.pem +> /etc/shibboleth/sp-cert.pem + +2. ***/etc/httpd/conf.d/ssl.conf*** +> including: +> ServerName fqdn:port +> UseCanonicalName On + +3. ***/etc/shibboleth/shibboleth2.xml*** +> including: +> entityID +

+ ***New in the 3.0 release:*** +>The image is based from the public CentOS7 image +>The TIER logging format has been implemented for shibd and httpd +>Everything now runs under supervisord +>The TIER Beacon has been implemented +>The file */etc/httpd/conf.d/ssl.conf* is now the default CentOS7 file diff --git a/container_files/system/httpd-shib-foreground b/container_files/system/httpd-shib-foreground deleted file mode 100755 index 60a415f..0000000 --- a/container_files/system/httpd-shib-foreground +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -e - -# Apache gets grumpy about PID files pre-existing -rm -f /etc/httpd/logs/httpd.pid - -(/usr/sbin/shibd) & httpd -DFOREGROUND diff --git a/container_files/system/sendtierbeacon.sh b/container_files/system/sendtierbeacon.sh new file mode 100755 index 0000000..7496968 --- /dev/null +++ b/container_files/system/sendtierbeacon.sh @@ -0,0 +1,28 @@ +#!/bin/bash +LOGHOST="collector.testbed.tier.internet2.edu" +LOGPORT="5001" +if [ -s /opt/tier/env.bash ]; then + . /opt/tier/env.bash +fi + +#JSON/REST style +LOGTEXT="{ \"msgType\" : \"TIERBEACON\", \"msgName\" : \"TIER\", \"msgVersion\" : \"1.0\", \"tbProduct\" : \"$IMAGENAME\", \"tbProductVersion\" : \"$VERSION\", \"tbTIERRelease\" : \"$TIERVERSION\", \"tbMaintainer\" : \"$MAINTAINER\" }" + + +if [ -z "$TIER_BEACON_OPT_OUT" ]; then + #send JSON + echo $LOGTEXT > msgjson.txt + curl -s -XPOST "${LOGHOST}:${LOGPORT}/" -H 'Content-Type: application/json' -T msgjson.txt 1>/dev/null + if [ $? -eq 0 ]; then + echo "tier_beacon;none;$ENV;$USERTOKEN;"`date`"; TIER beacon sent" + else + echo "tier_beacon;none;$ENV;$USERTOKEN;"`date`"; Failed to send TIER beacon" + fi + + rm -f msgjson.txt + + #below is for syslog, F-TICKS style + #`logger -n $LOGHOST -P $LOGPORT -t TIERBEACON $LOGTEXT` + +fi + diff --git a/container_files/system/setenv.sh b/container_files/system/setenv.sh new file mode 100755 index 0000000..55c8c89 --- /dev/null +++ b/container_files/system/setenv.sh @@ -0,0 +1,6 @@ +#!/bin/bash +printenv | sed 's/^\(.*\)$/\1/g' | grep -E "^VERSION" > /opt/tier/env.bash +printenv | sed 's/^\(.*\)$/\1/g' | grep -E "^TIERVERSION" >> /opt/tier/env.bash +printenv | sed 's/^\(.*\)$/\1/g' | grep -E "^IMAGE" >> /opt/tier/env.bash +printenv | sed 's/^\(.*\)$/\1/g' | grep -E "^MAINTAINER" >> /opt/tier/env.bash + diff --git a/container_files/system/setupcron.sh b/container_files/system/setupcron.sh new file mode 100755 index 0000000..3cabd35 --- /dev/null +++ b/container_files/system/setupcron.sh @@ -0,0 +1,18 @@ +#!/bin/bash +CRONFILE=/opt/tier/tier-cron + +#set env vars for cron job +# this script creates /opt/tier/env.bash which is sourced by the cron job's script, which was not seeing the environment set by the Dockerfile +/opt/tier/setenv.sh + +#build crontab file with random start time between midnight and 3:59am +echo "#send daily beacon to TIER Central" > ${CRONFILE} +echo $(expr $RANDOM % 59) $(expr $RANDOM % 3) "* * * /usr/local/bin/sendtierbeacon.sh >> /var/log/cron.log 2>&1" >> ${CRONFILE} +chmod 644 ${CRONFILE} + +#install crontab +crontab ${CRONFILE} + +#create cron logfile +touch /var/log/cron.log + diff --git a/container_files/system/startup.sh b/container_files/system/startup.sh new file mode 100755 index 0000000..b5f0d3a --- /dev/null +++ b/container_files/system/startup.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +#for passed-in env vars, remove spaces and replace any ; with : in usertoken env var since we will use ; as a delimiter +export USERTOKEN="${USERTOKEN//;/:}" +export USERTOKEN="${USERTOKEN// /}" +export ENV="${ENV//;/:}" +export ENV="${ENV// /}" + +# generic console logging pipe for anyone +mkfifo -m 666 /tmp/logpipe +cat <> /tmp/logpipe 1>&2 & + +mkfifo -m 666 /tmp/logcrond +(cat <> /tmp/logcrond | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "crond;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' 1>/tmp/logpipe) & + +mkfifo -m 666 /tmp/loghttpd +(cat <> /tmp/loghttpd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "httpd;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' 1>/tmp/logpipe) & + +mkfifo -m 666 /tmp/logsuperd +(cat <> /tmp/logsuperd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "supervisord;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' 1>/tmp/logpipe) & + +mkfifo -m 666 /tmp/logshibd +(cat <> /tmp/logshibd | awk -v ENV="$ENV" -v UT="$USERTOKEN" '{printf "shibd;console;%s;%s;%s\n", ENV, UT, $0; fflush()}' 1>/tmp/logpipe) & + +#launch supervisord +/usr/bin/supervisord -c /etc/supervisor/supervisord.conf + diff --git a/container_files/system/supervisord.conf b/container_files/system/supervisord.conf new file mode 100644 index 0000000..e25dd78 --- /dev/null +++ b/container_files/system/supervisord.conf @@ -0,0 +1,37 @@ +[supervisord] +logfile=/tmp/logsuperd +logfile_maxbytes=0 +loglevel=error +nodaemon=true +user=root + +[program:cron] +command=/usr/sbin/crond -n +autostart=true +autorestart=true +stdout_logfile=/tmp/logcrond +stdout_logfile_maxbytes=0 +stderr_logfile=/tmp/logcrond +stderr_logfile_maxbytes=0 +directory=/usr/bin + +[program:httpd] +command=httpd -DFOREGROUND +autostart=true +autorestart=true +stdout_logfile=/tmp/loghttpd +stdout_logfile_maxbytes=0 +stderr_logfile=/tmp/loghttpd +stderr_logfile_maxbytes=0 + +[program:shibd] +command=/usr/sbin/shibd +autostart=true +autorestart=true +stdout_logfile=/tmp/logshibd +stdout_logfile_maxbytes=0 +stderr_logfile=/tmp/logshibd +stderr_logfile_maxbytes=0 + +[include] +files=/etc/supervisor/conf.d/* diff --git a/tests/clairscan.sh b/tests/clairscan.sh new file mode 100755 index 0000000..a06ea78 --- /dev/null +++ b/tests/clairscan.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +startsecs=$(date +'%s') +starttime=$(date +%H:%M:%S) + +echo 'starting:' ${starttime} + +#ensure clair-scanner +if [ ! -s ./clair-scanner ]; then + echo 'downloading curl-scanner...' + curl -s -L -o ./clair-scanner https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64 + chmod 755 clair-scanner +else + echo 'using existing clair-scanner...' +fi + +#ensure DB container +echo 'ensuring a fresh clair-db container...' +docker ps | grep clair-db &>/dev/null +if [ $? == "0" ]; then + echo 'removing existing clair-db container...' + docker kill db &>/dev/null + docker rm db &>/dev/null + docker run -p 5432:5432 -d --name db arminc/clair-db:latest &>/dev/null +else + docker run -p 5432:5432 -d --name db arminc/clair-db:latest &>/dev/null +fi +sleep 30 + +#ensure clair-scan container +echo 'ensuring a fresh clair-scan container...' +docker ps | grep clair-local-scan &>/dev/null +if [ $? == "0" ]; then + echo 'removing existing clair-scan container...' + docker kill clair &>/dev/null + docker rm clair &>/dev/null + docker run -p 6060:6060 --link db:postgres -d --name clair arminc/clair-local-scan:v2.0.5 &>/dev/null +else + docker run -p 6060:6060 --link db:postgres -d --name clair arminc/clair-local-scan:v2.0.5 &>/dev/null +fi +sleep 30 + +#get ip where clair-scanner will listen +clairip=$(/sbin/ifconfig docker0 | grep 'inet ' | sed 's/^[[:space:]]*//g' | cut -f 2 -d ' ' | sed 's/^[[:space:]]*//g') +echo 'sending ip addr' ${clairip} 'to clair-scan server...' + +#run scan +echo 'running scan...' +./clair-scanner --ip ${clairip} $1 +retcode=$? + +#eval results +if [ $retcode == '0' ]; then + echo 'scan found nothing.' +else + echo 'scan found issues.' +fi + +#cleanup +echo 'removing temporary containers...' +docker kill clair &>/dev/null +docker rm clair &>/dev/null +docker kill db &>/dev/null +docker rm db &>/dev/null + +endsecs=$(date +'%s') +endtime=$(date +%H:%M:%S) +echo 'finished:' $endtime ' ('$((endsecs - startsecs)) 'seconds)' +echo "" + +#pass along return code from scan +exit $retcode + diff --git a/tests/image.bats b/tests/image.bats index 3d9fb5e..2ab8f4b 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -26,3 +26,6 @@ load ../common docker run -i $maintainer/$imagename find /usr/local/bin/httpd-shib-foreground } +@test "070 There are no known security vulnerabilities" { + ./tests/clairscan.sh ${maintainer}/${imagename}:latest +} From 6ed19997a551e42db9a831b0b9ebf3164070fbf8 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Sat, 13 Oct 2018 16:40:49 +0000 Subject: [PATCH 06/16] fix test --- README.md | 11 +++++------ tests/image.bats | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3c2eced..1a41af3 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,9 @@ Files you must supply/override in your downstream builds: > entityID

***New in the 3.0 release:*** ->The image is based from the public CentOS7 image ->The TIER logging format has been implemented for shibd and httpd ->Everything now runs under supervisord ->The TIER Beacon has been implemented ->The file */etc/httpd/conf.d/ssl.conf* is now the default CentOS7 file - +* The image is based from the public CentOS7 image +* The TIER logging format has been implemented for shibd and httpd +* Everything now runs under supervisord +* The TIER Beacon has been implemented +* The file */etc/httpd/conf.d/ssl.conf* is now the default CentOS7 file diff --git a/tests/image.bats b/tests/image.bats index 2ab8f4b..070a19f 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -22,8 +22,8 @@ load ../common docker run -i $maintainer/$imagename find /usr/local/bin/shibboleth_keygen.sh } -@test "Includes httpd + shibd startup script" { - docker run -i $maintainer/$imagename find /usr/local/bin/httpd-shib-foreground +@test "Includes startup script" { + docker run -i $maintainer/$imagename find /usr/local/bin/startup.sh } @test "070 There are no known security vulnerabilities" { From e9dab8eaec5a07d1301fef30ce0cb517d681a426 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Sat, 13 Oct 2018 20:52:36 +0000 Subject: [PATCH 07/16] fix supervisord cfg --- Dockerfile | 2 -- README.md | 13 ++++++++----- container_files/system/supervisord.conf | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 06810e5..79a9428 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,10 +34,8 @@ RUN curl -o /etc/yum.repos.d/security:shibboleth.repo \ RUN LD_LIBRARY_PATH="/opt/shibboleth/lib64" RUN export LD_LIBRARY_PATH -ADD ./container_files/system/shibboleth_keygen.sh /usr/local/bin/ ADD ./container_files/httpd/ssl.conf /etc/httpd/conf.d/ ADD ./container_files/shibboleth/* /etc/shibboleth/ -RUN chmod +x /usr/local/bin/shibboleth_keygen.sh # fix httpd logging to tier format RUN sed -i 's/LogFormat "/LogFormat "httpd;access_log;%{ENV}e;%{USERTOKEN}e;/g' /etc/httpd/conf/httpd.conf \ diff --git a/README.md b/README.md index 1a41af3..32be5b5 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,15 @@ It is based from CentOS 7 and includes httpd, mod_ssl, and the current shibbolet Files you must supply/override in your downstream builds: -1. The SP's ***private key and corresponding certificate*** (very important!), which can be generated in your downstream container like this: -> RUN /usr/local/bin/shibboleth_keygen.sh -o /etc/shibboleth -f +1. The SP's ***private keys and corresponding certificates*** (very important!), which can be generated in your downstream container like this: +> RUN /etc/shibboleth/keygen.sh -o /etc/shibboleth/ -y 10 -n sp-encrypt -f \ +> && /etc/shibboleth/keygen.sh -o /etc/shibboleth/ -y 10 -n sp-signing -f > -> ...that command generates/overwrites the following files: -> /etc/shibboleth/sp-key.pem -> /etc/shibboleth/sp-cert.pem +> ...those commands generate/overwrite the following files: +> /etc/shibboleth/sp-encrypt-key.pem +> /etc/shibboleth/sp-encrypt-cert.pem +> /etc/shibboleth/sp-signing-key.pem +> /etc/shibboleth/sp-signing-cert.pem 2. ***/etc/httpd/conf.d/ssl.conf*** > including: diff --git a/container_files/system/supervisord.conf b/container_files/system/supervisord.conf index e25dd78..d63f5f0 100644 --- a/container_files/system/supervisord.conf +++ b/container_files/system/supervisord.conf @@ -25,7 +25,7 @@ stderr_logfile=/tmp/loghttpd stderr_logfile_maxbytes=0 [program:shibd] -command=/usr/sbin/shibd +command=/usr/sbin/shibd -f autostart=true autorestart=true stdout_logfile=/tmp/logshibd From 0929c3841b2af414fd0f617d4c8db6660c80df12 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Sat, 13 Oct 2018 20:56:34 +0000 Subject: [PATCH 08/16] fix test --- tests/image.bats | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/image.bats b/tests/image.bats index 070a19f..792cede 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -18,10 +18,6 @@ load ../common docker run -i $maintainer/$imagename find /etc/shibboleth/inc-md-cert.pem } -@test "Includes Shibboleth keygenerator" { - docker run -i $maintainer/$imagename find /usr/local/bin/shibboleth_keygen.sh -} - @test "Includes startup script" { docker run -i $maintainer/$imagename find /usr/local/bin/startup.sh } From 7160c7adec82bdc9551efa1ed75cbdbeab6ae4aa Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Sat, 27 Oct 2018 04:00:33 +0000 Subject: [PATCH 09/16] update shibboleth_keygen.sh --- container_files/system/shibboleth_keygen.sh | 47 ++++++++++++++------- 1 file changed, 32 insertions(+), 15 deletions(-) mode change 100755 => 100644 container_files/system/shibboleth_keygen.sh diff --git a/container_files/system/shibboleth_keygen.sh b/container_files/system/shibboleth_keygen.sh old mode 100755 new mode 100644 index 205792e..f6d17ab --- a/container_files/system/shibboleth_keygen.sh +++ b/container_files/system/shibboleth_keygen.sh @@ -1,29 +1,37 @@ #! /bin/sh -while getopts h:u:g:o:e:y:bf c +while getopts n:h:u:g:o:e:y:bf c do case $c in + u) USER=$OPTARG;; + g) GROUP=$OPTARG;; o) OUT=$OPTARG;; b) BATCH=1;; f) FORCE=1;; h) FQDN=$OPTARG;; e) ENTITYID=$OPTARG;; y) YEARS=$OPTARG;; - \?) echo "shibboleth_keygen [-o output directory (default .)] [-h hostname for cert] [-y years to issue cert] [-e entityID to embed in cert]" + n) PREFIX=$OPTARG;; + \?) echo "keygen [-o output directory (default .)] [-u username to own keypair] [-g owning groupname] [-h hostname for cert] [-y years to issue cert] [-e entityID to embed in cert] [-n filename prefix (default 'sp')]" exit 1;; esac done + if [ -z "$OUT" ] ; then OUT=. fi +if [ -z "$PREFIX" ]; then + PREFIX="sp" +fi + if [ -n "$FORCE" ] ; then - rm $OUT/sp-key.pem $OUT/sp-cert.pem + rm $OUT/${PREFIX}-key.pem $OUT/${PREFIX}-cert.pem fi -if [ -s $OUT/sp-key.pem -o -s $OUT/sp-cert.pem ] ; then +if [ -s $OUT/${PREFIX}-key.pem -o -s $OUT/${PREFIX}-cert.pem ] ; then if [ -z "$BATCH" ] ; then - echo The files $OUT/sp-key.pem and/or $OUT/sp-cert.pem already exist! + echo The files $OUT/${PREFIX}-key.pem and/or $OUT/${PREFIX}-cert.pem already exist! echo Use -f option to force recreation of keypair. exit 2 fi @@ -31,7 +39,7 @@ if [ -s $OUT/sp-key.pem -o -s $OUT/sp-cert.pem ] ; then fi if [ -z "$FQDN" ] ; then - FQDN=`hostname --fqdn` + FQDN=`hostname` fi if [ -z "$YEARS" ] ; then @@ -46,14 +54,14 @@ else ALTNAME=DNS:$FQDN,URI:$ENTITYID fi -SSLCNF=$OUT/sp-cert.cnf +SSLCNF=$OUT/${PREFIX}-cert.cnf cat >$SSLCNF < /dev/null + openssl req -config $SSLCNF -new -x509 -days $DAYS -keyout $OUT/${PREFIX}-key.pem -out $OUT/${PREFIX}-cert.pem 2> /dev/null +fi +rm $SSLCNF + +if [ -s $OUT/${PREFIX}-key.pem -a -n "$USER" ] ; then + chown $USER $OUT/${PREFIX}-key.pem $OUT/${PREFIX}-cert.pem fi -rm $SSLCNF \ No newline at end of file + +if [ -s $OUT/${PREFIX}-key.pem -a -n "$GROUP" ] ; then + chgrp $GROUP $OUT/${PREFIX}-key.pem $OUT/${PREFIX}-cert.pem +fi + From 110e58ee4ce7c7399f49441b4b28b76007d48bfe Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Thu, 20 Dec 2018 06:59:09 -0600 Subject: [PATCH 10/16] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 79a9428..32369ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM centos:centos7 # Define args and set a default value ARG maintainer=tier ARG imagename=shibboleth_sp -ARG version=3.0.2 +ARG version=3.0.3 MAINTAINER $maintainer LABEL Vendor="Internet2" From cde5c80638463a4fa54c14d5f347602542271ee3 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Thu, 20 Dec 2018 07:03:21 -0600 Subject: [PATCH 11/16] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 00be48b..a5fc161 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,7 @@ node('docker') { git([ url: "https://github.internet2.edu/docker/util.git", credentialsId: "jenkins-github-access-token" ]) sh 'ls' + sh 'rm -rf ../bin/*' sh 'mv bin/* ../bin/.' } stage 'Setting build context' From f33fa8dd1d446160fad70b59f47afce7b5eb8288 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Thu, 20 Dec 2018 07:05:51 -0600 Subject: [PATCH 12/16] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a5fc161..d7a12eb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,7 +40,7 @@ node('docker') { sh 'bin/rebuild.sh &> debug' } catch(error) { def error_details = readFile('./debug'); - def message = "BUILD ERROR: There was a problem building the shibboleth-sp mage. \n\n ${error_details}" + def message = "BUILD ERROR: There was a problem building the shibboleth-sp image. \n\n ${error_details}" sh "rm -f ./debug" handleError(message) } From 8b9ffb469ad5765678d7772eb28dbb6745fe9c09 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Thu, 20 Dec 2018 07:13:45 -0600 Subject: [PATCH 13/16] Update common.bash --- common.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.bash b/common.bash index 8c19ea3..2053ebe 100644 --- a/common.bash +++ b/common.bash @@ -1,3 +1,3 @@ maintainer="tier" imagename="shibboleth_sp" -version="3.0.2" +version="3.0.3" From 46bcc2fd404be8b0784d80370f4a2e7fc942b5cd Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Thu, 20 Dec 2018 07:38:44 -0600 Subject: [PATCH 14/16] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7a12eb..74578ef 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ node('docker') { git([ url: "https://github.internet2.edu/docker/util.git", credentialsId: "jenkins-github-access-token" ]) sh 'ls' - sh 'rm -rf ../bin/*' + sh 'rm -rf ../bin/windows/' sh 'mv bin/* ../bin/.' } stage 'Setting build context' From 0d909c3bd163bdf583554c61251668f0270ba24f Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Fri, 21 Dec 2018 09:03:26 -0600 Subject: [PATCH 15/16] Update supervisord.conf --- container_files/system/supervisord.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/container_files/system/supervisord.conf b/container_files/system/supervisord.conf index d63f5f0..952bed5 100644 --- a/container_files/system/supervisord.conf +++ b/container_files/system/supervisord.conf @@ -32,6 +32,7 @@ stdout_logfile=/tmp/logshibd stdout_logfile_maxbytes=0 stderr_logfile=/tmp/logshibd stderr_logfile_maxbytes=0 +environment=LD_LIBRARY_PATH=/opt/shibboleth/lib64 [include] files=/etc/supervisor/conf.d/* From 7da78acc27bae121db57eff451bb5e82da91aa52 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Tue, 12 Mar 2019 06:43:56 -0500 Subject: [PATCH 16/16] update to 3.0.4 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 32369ca..8d96741 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM centos:centos7 # Define args and set a default value ARG maintainer=tier ARG imagename=shibboleth_sp -ARG version=3.0.3 +ARG version=3.0.4 MAINTAINER $maintainer LABEL Vendor="Internet2"