Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
handnot2 committed Sep 7, 2017
0 parents commit 1503aa5
Show file tree
Hide file tree
Showing 20 changed files with 1,149 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sspdv
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM php:fpm-alpine

ENV SAML_VERSION 1.14.16

RUN set -xe \
&& apk add --no-cache openssl \
&& apk add --no-cache php5-mcrypt \
&& apk add --no-cache php5-ldap \
&& buildDeps="wget ca-certificates" \
&& apk add --no-cache $buildDeps \
&& update-ca-certificates \
&& rm -rf /var/cache/apk/* \
&& wget https://github.com/simplesamlphp/simplesamlphp/releases/download/v${SAML_VERSION}/simplesamlphp-${SAML_VERSION}.tar.gz \
-O /tmp/simplesamlphp-${SAML_VERSION}.tar.gz --no-check-certificate \
&& tar -zxf /tmp/simplesamlphp-${SAML_VERSION}.tar.gz -C /tmp \
&& mv /tmp/simplesamlphp-${SAML_VERSION} /srv/simplesaml \
&& wget https://github.com/bander2/twit/releases/download/1.1.0/twit-linux-amd64 \
-O /usr/local/bin/twit --secure-protocol=TLSv1 \
&& chmod u+x /usr/local/bin/twit \
&& mkdir /lib64 \
&& ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 \
&& apk del $buildDeps

EXPOSE 9000

WORKDIR /srv/simplesaml

VOLUME ["/srv/simplesaml"]

CMD ["php-fpm"]
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2017 handnot2 ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 changes: 21 additions & 0 deletions attributions
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
https://github.com/hcpss-banderson/docker-simplesamlphp

Copyright (c) 2016 Howard County Public School System

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
sudo docker --debug=true build -t "samlysaml" -f Dockerfile . --no-cache
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '2.1'

services:
setup:
image: samlysaml
volumes:
- ./setup:/setup
- ./sspdv:/sspdv
command: /setup/init.sh

idp:
image: php:fpm-alpine
depends_on:
- setup
volumes_from:
- setup
expose:
- 9000

web:
image: nginx:alpine
depends_on:
- idp
ports:
- "8082:8082" # keep this consistent with setup/params/params.yml
volumes_from:
- setup
volumes:
- ./sspdv/nginx/conf.d/site.conf:/etc/nginx/conf.d/default.conf
links:
- idp
59 changes: 59 additions & 0 deletions setup/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/sh

SRC_DIR="/setup"
GEN_DIR="/sspdv"

SSP_DIR="/srv/simplesaml"

mkdir -p ${GEN_DIR}/cert
mkdir -p ${GEN_DIR}/nginx/conf.d
touch ${GEN_DIR}/nginx/conf.d/site.conf

if [ ! -f ${GEN_DIR}/cert/server.crt ];
then
C="US"
ST="Midlands"
L="Safeville"
O="ID Federation"
OU="Department of Identities"
CN="my.idp"
SUBJ="/C=${C}/ST=${ST}/L=${L}/O=${O}/OU=${OU}/CN=${CN}"

echo "Generating IDP Certificate ..."
openssl req -new -x509 -sha256 -days 365 -nodes \
-newkey rsa:4096 \
-out ${GEN_DIR}/cert/server.crt \
-keyout ${GEN_DIR}/cert/server.pem \
-subj "${SUBJ}"
fi

if [ -d ${SRC_DIR}/sp ];
then
echo "Copying SP cert ..."
cp -r ${SRC_DIR}/sp ${SSP_DIR}/cert/
fi
cp -f ${GEN_DIR}/cert/server.crt ${SSP_DIR}/cert/
cp -f ${GEN_DIR}/cert/server.pem ${SSP_DIR}/cert/

for i in `cat ${SRC_DIR}/templates/nginx.config`
do
f=`echo $i | sed 's/\.tpl$//' -`
twit ${SRC_DIR}/templates/${i} ${GEN_DIR}/nginx/conf.d/${f} \
-p ${SRC_DIR}/params/defaults.yml -p ${SRC_DIR}/params/params.yml -n
done

for i in `cat ${SRC_DIR}/templates/ssp.config`
do
f=`echo $i | sed 's/\.tpl$//' -`
twit ${SRC_DIR}/templates/${i} ${SSP_DIR}/config/${f} \
-p ${SRC_DIR}/params/defaults.yml -p ${SRC_DIR}/params/params.yml -n
done

for i in `cat ${SRC_DIR}/templates/ssp.metadata`
do
f=`echo $i | sed 's/\.tpl$//' -`
twit ${SRC_DIR}/templates/${i} ${SSP_DIR}/metadata/${f} \
-p ${SRC_DIR}/params/defaults.yml -p ${SRC_DIR}/params/params.yml -n
done

touch ${SSP_DIR}/modules/exampleauth/default-enable
58 changes: 58 additions & 0 deletions setup/params/defaults.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
entity_id: entity
secretsalt: salt
authsources: []
user: []
metadata: []

# Config
baseurlpath: http://localhost:8080/simplesaml/
certdir: cert/
loggingdir: log/
datadir: data/
tempdir: /tmp/simplesaml
debug: False
showerrors: False
errorreporting: False
debug_validatexml: False
auth_adminpassword: changeme
admin_protectindexpage: True
admin_protectmetadata: True
secretsalt: salt
technicalcontact_name: John Doe
technicalcontact_email: [email protected]
timezone: America/New_York
loggin_level: NOTICE
logging_handler: syslog
enable_saml20_idp: False
enable_shib13_idp: False
enable_adfs_idp: False
enable_wsfed_sp: False
enable_authmemcookie: False

# Session
session_durration: 28800
session_datastore_timeout: 14400
session_state_timeout: 3600
cookie_name: SamlySimpleSAMLSessionID
session_cookie_lifetime: 0
session_cookie_domain: null
session_cookie_secure: False
session_disable_fallback: False
enable_http_post: False
session_phpsession_cookiename: null
session_phpsession_savepath: null
session_phpsession_httponly: True
session_authtoken_cookiename: SamlySimpleSAMLAuthToken
session_rememberme_enable: False
session_rememberme_checked: False
session_rememberme_lifetime: 1209600

# Language
language_default: en
language_parameter_name: language
language_parameter_setcookie: True
language_cookie_name: language
language_cookie_domain: null
language_cookie_path: /
language_cookie_lifetime: 77760000
37 changes: 37 additions & 0 deletions setup/params/params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
idp_host: samly.idp
idp_port: 8082
baseurlpath: http://samly.idp:8082/simplesaml/
secretsalt: changeme_to_a_long_random_salt
auth_adminpassword: changeme
admin_protectindexpage: True
admin_protectmetadata: False
technicalcontact_name: Jane Doe
technicalcontact_email: [email protected]
timezone: America/New_York
enable_saml20_idp: True
debug: True
showerrors: False
loggin_level: DEBUG
logging_handler: file
loggingdir: /tmp/
debug_validatexml: True

service_providers:
- base_url: http://samly.howto:4003/sso
name: samly_howto
certificate: sp/samly_howto/sp.crt

authsources:
- name: example-userpass

users:
- uid: fred
email: [email protected]
password: changeme
- uid: wilma
email: [email protected]
password: changeme
- uid: dino
email: [email protected]
password: changeme
Empty file added setup/sp/.gitkeep
Empty file.
20 changes: 20 additions & 0 deletions setup/templates/authsources.php.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

$config = array(
// This is a authentication source which handles admin authentication.
'admin' => array(
// The default is to use core:AdminPassword, but it can be replaced with
// any authentication source.
'core:AdminPassword',
),

'example-userpass' => array(
'exampleauth:UserPass',
{{ range $user := .users }}
'{{ $user.uid }}:{{ $user.password }}' => array(
'uid' => array('{{ $user.uid }}'),
'email' => array('{{ $user.email }}')
),
{{ end }}
),
);
Loading

0 comments on commit 1503aa5

Please sign in to comment.