From 5078b97f0076145084c3eb4002e60c0b07f13238 Mon Sep 17 00:00:00 2001 From: Martin van Es Date: Tue, 30 Apr 2024 11:01:20 +0200 Subject: [PATCH 1/4] Fixes for ssphp 2.2.1 --- deploy.sh | 2 + group_vars/idp.yml | 12 +- group_vars/logins.json | 78 +- inventory | 2 +- roles/common/tasks/main.yml | 34 +- roles/common/vars/packages.yml | 17 +- roles/common/vars/repositories.yml | 12 +- roles/letsencrypt/defaults/main.yml | 2 +- roles/letsencrypt/tasks/cert.yaml | 8 +- roles/letsencrypt/tasks/client.yaml | 5 +- roles/letsencrypt/tasks/main.yml | 2 +- roles/letsencrypt/vars/main.yml | 2 +- roles/simplesaml/defaults/main.yml | 21 +- roles/simplesaml/tasks/main.yml | 96 +- .../simplesaml/templates/config/config.php.j2 | 1305 +++++++++++++---- .../metadata/saml20-idp-remote.php.j2 | 9 + roles/ssl/templates/apache.conf.j2 | 2 +- 17 files changed, 1152 insertions(+), 457 deletions(-) create mode 100755 deploy.sh create mode 100644 roles/simplesaml/templates/metadata/saml20-idp-remote.php.j2 diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..3135624 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,2 @@ +#!/bin/sh +ansible-playbook -i inventory --ask-become-pass openconext-diy.yml diff --git a/group_vars/idp.yml b/group_vars/idp.yml index 65344b8..80c3a50 100644 --- a/group_vars/idp.yml +++ b/group_vars/idp.yml @@ -1,16 +1,16 @@ # Site information -idp_hostname: idp.example.org -idp_sp: https://sp.example.org +idp_hostname: idp.maes1.lab.surf.nl +idp_sp: https://sp.maes1.lab.surf.nl cert_hostname: "{{ idp_hostname }}" -letsencrypt_email: idp@example.org +letsencrypt_email: "admin@{{ idp_hostname }}" letsencrypt_domain: "{{ idp_hostname }}" letsencrypt_request_www: false # apache is installed first and claims port 80. Pause it to allow LetsEncrypt to request a certificate letsencrypt_pause_services: [apache2] -ssp_version: 1.18.8 +ssp_version: 2.2.1 ssp_hostname: "{{ idp_hostname }}" ssp_subject: "{{ cert_subject }}" ssp_days_valid: "{{ cert_days_valid }}" @@ -19,12 +19,10 @@ ssp_certificate: "{{ idp_hostname }}.crt" ssp_auth_admin_password: "changethispassword" ssp_technicalcontact_name: Contact ssp_technicalcontact_email: postmaster@{{ idp_hostname }} -ssp_managingcontact_name: Manager -ssp_managingcontact_email: webmaster@{{ idp_hostname }} spp_sp_metadata: "{{ idp_sp }}/authentication/sp/metadata" spp_sp_consumer: "{{ idp_sp }}/authentication/sp/consume-assertion" ssp_title_suffix: OpenConext-DIY2 ssl_hostname: "{{ idp_hostname }}" ssl_webmaster: "webmaster@{{ ssl_hostname }}" -ssl_docroot: "{{ ssp_dir }}/www" +ssl_docroot: "{{ ssp_dir }}/public" diff --git a/group_vars/logins.json b/group_vars/logins.json index 53eee0d..dc072a8 100644 --- a/group_vars/logins.json +++ b/group_vars/logins.json @@ -176,7 +176,7 @@ "student6:student6" : { "uid" : ["U6789003"], "schacHomeOrganization" : "home-university-example.org", - "eduPersonPrincipalName" : "U6789003@home-university-example.org", + "eduPersonPrincipalName" : "U6789003@home-university-example.org", "cn" : "Phùng Thị Lệ Tư", "givenName" : "Phùng Thị", "sn" : "Lệ Tư", @@ -190,7 +190,7 @@ "student7:student7" : { "uid" : ["jsanden"], "schacHomeOrganization" : "uniamsterdam-example.nl", - "eduPersonPrincipalName" : "jsanden@uniamsterdam-example.nl", + "eduPersonPrincipalName" : "jsanden@uniamsterdam-example.nl", "cn" : "Jaantje van der Sanden", "givenName" : "Jaantje", "sn" : "van der Sanden", @@ -204,7 +204,7 @@ "student8:student8" : { "uid" : ["s445599"], "schacHomeOrganization" : "universitatmadrid-example.es", - "eduPersonPrincipalName" : "s445599@universitatmadrid-example.es", + "eduPersonPrincipalName" : "s445599@universitatmadrid-example.es", "cn" : "Alessandra Gómez Llarnas", "givenName" : "Alessandra", "sn" : "Gómez Llarnas", @@ -217,7 +217,7 @@ "student9:student9" : { "uid" : ["abriseno"], "schacHomeOrganization" : "universitatmadrid-example.es", - "eduPersonPrincipalName" : "abriseno@universitatmadrid-example.es", + "eduPersonPrincipalName" : "abriseno@universitatmadrid-example.es", "cn" : "Augustus Padrón Briseño", "givenName" : "August", "sn" : "Briseño", @@ -230,7 +230,7 @@ "student10:student10" : { "uid" : ["s134567"], "schacHomeOrganization" : "pkuni.edu-example.cn", - "eduPersonPrincipalName" : "s134567@pkuni.edu-example.cn", + "eduPersonPrincipalName" : "s134567@pkuni.edu-example.cn", "cn" : "Shao Jingyi, 邵靜宜", "givenName" : "Shao", "sn" : "Jingy", @@ -243,7 +243,7 @@ "student11:student11" : { "uid" : ["U9088123"], "schacHomeOrganization" : "uni.poznantech-example.pl", - "eduPersonPrincipalName" : "U9088123@uni.poznantech-example.pl", + "eduPersonPrincipalName" : "U9088123@uni.poznantech-example.pl", "cn" : "Roman Švejda", "givenName" : "Roman", "sn" : "Švejda", @@ -256,7 +256,7 @@ "student12:student12" : { "uid" : ["U7128109"], "schacHomeOrganization" : "uni.poznantech-example.pl", - "eduPersonPrincipalName" : "U7128109@uni.poznantech-example.pl", + "eduPersonPrincipalName" : "U7128109@uni.poznantech-example.pl", "cn" : "Anna Rybínová", "givenName" : "Anna", "sn" : "Rybínová", @@ -269,7 +269,7 @@ "student13:student13" : { "uid" : ["p0987743"], "schacHomeOrganization" : "pkuni.edu-example.cn", - "eduPersonPrincipalName" : "p0987743@pkuni.edu-example.cn", + "eduPersonPrincipalName" : "p0987743@pkuni.edu-example.cn", "cn" : "Li Qin Ch'ien", "givenName" : "Li Qin", "sn" : "Ch'ien", @@ -282,7 +282,7 @@ "student14:student14" : { "uid" : ["student14"], "schacHomeOrganization" : "stockholmuni-example.se", - "eduPersonPrincipalName" : "student14@stockholmuni-example.se", + "eduPersonPrincipalName" : "student14@stockholmuni-example.se", "cn" : "Martin Nikolaus Jørgensen", "givenName" : "Martin", "sn" : "Jørgensen", @@ -295,7 +295,7 @@ "student15:student15" : { "uid" : ["student15"], "schacHomeOrganization" : "stockholmuni-example.se", - "eduPersonPrincipalName" : "student15@stockholmuni-example.se", + "eduPersonPrincipalName" : "student15@stockholmuni-example.se", "cn" : "Sander Johan Kjær", "givenName" : "Sander", "sn" : "Kjær", @@ -308,7 +308,7 @@ "student16:student16" : { "uid" : ["student16"], "schacHomeOrganization" : "kuni.edu-example.tr", - "eduPersonPrincipalName" : "student16@kuni.edu-example.tr", + "eduPersonPrincipalName" : "student16@kuni.edu-example.tr", "cn" : "Erôss Neci", "givenName" : "Erôss", "sn" : "Neci", @@ -322,7 +322,7 @@ "student17:student17" : { "uid" : ["student17"], "schacHomeOrganization" : "kuni.edu-example.tr", - "eduPersonPrincipalName" : "student17@kuni.edu-example.tr", + "eduPersonPrincipalName" : "student17@kuni.edu-example.tr", "cn" : "Kocsis Szescõ", "givenName" : "Kocsis", "sn" : "Szescõ", @@ -335,7 +335,7 @@ "student18:student18" : { "uid" : ["student18"], "schacHomeOrganization" : "kuni.edu-example.tr", - "eduPersonPrincipalName" : "student18@kuni.edu-example.tr", + "eduPersonPrincipalName" : "student18@kuni.edu-example.tr", "cn" : "Marjanca Muršić", "givenName" : "Marjanca", "sn" : "Muršić", @@ -348,7 +348,7 @@ "student19:student19" : { "uid" : ["student19"], "schacHomeOrganization" : "university-example.org", - "eduPersonPrincipalName" : "student19@university-example.org", + "eduPersonPrincipalName" : "student19@university-example.org", "cn" : "Petra Penttilä", "givenName" : "Petra", "sn" : "Penttilä", @@ -361,7 +361,7 @@ "student20:student20" : { "uid" : ["student20"], "schacHomeOrganization" : "unidenmark-example.dk", - "eduPersonPrincipalName" : "student20@unidenmark-example.dk", + "eduPersonPrincipalName" : "student20@unidenmark-example.dk", "cn" : "Jóney Ingólfsdóttir", "givenName" : "Jóney", "sn" : "Ingólfsdóttir", @@ -374,7 +374,7 @@ "student21:student21" : { "uid" : ["student21"], "schacHomeOrganization" : "exmplebilbioharderwijk.nl", - "eduPersonPrincipalName" : "student21@exmplebilbioharderwijk.nl", + "eduPersonPrincipalName" : "student21@exmplebilbioharderwijk.nl", "cn" : "Pietje Puk", "givenName" : "Pietje", "sn" : "Puk", @@ -384,7 +384,7 @@ "teacher1:teacher1" : { "uid" : ["jstiglitz"], "schacHomeOrganization" : "harvard-example.edu", - "eduPersonPrincipalName" : "jstiglitz@harvard-example.edu", + "eduPersonPrincipalName" : "jstiglitz@harvard-example.edu", "cn" : "Joseph Eugene Stiglitz", "givenName" : "Joseph", "sn" : "Stiglitz", @@ -398,7 +398,7 @@ "teacher2:teacher2" : { "uid" : ["pkrugman"], "schacHomeOrganization" : "harvard-example.edu", - "eduPersonPrincipalName" : "pkrugman@harvard-example.edu", + "eduPersonPrincipalName" : "pkrugman@harvard-example.edu", "cn" : "Prof. Paul Robin Krugman", "givenName" : "Paul", "sn" : "Krugman", @@ -411,7 +411,7 @@ "teacher3:teacher3" : { "uid" : ["bbernanke"], "schacHomeOrganization" : "yale-uni-example.edu", - "eduPersonPrincipalName" : "bbernanke@yale-uni-example.edu", + "eduPersonPrincipalName" : "bbernanke@yale-uni-example.edu", "cn" : "Ben Shalom Bernanke", "givenName" : "Ben", "sn" : "Bernanke", @@ -424,7 +424,7 @@ "teacher4:teacher4" : { "uid" : ["agreenspan"], "schacHomeOrganization" : "yale-uni-example.edu", - "eduPersonPrincipalName" : "agreenspan@yale-uni-example.edu", + "eduPersonPrincipalName" : "agreenspan@yale-uni-example.edu", "cn" : "Alan Greenspan", "givenName" : "Alan", "sn" : "Greenspan", @@ -437,7 +437,7 @@ "teacher5:teacher5" : { "uid" : ["am_ampere"], "schacHomeOrganization" : "electrical-uni-example.edu", - "eduPersonPrincipalName" : "am_ampere@electrical-uni-example.edu", + "eduPersonPrincipalName" : "am_ampere@electrical-uni-example.edu", "cn" : "André-Marie Ampère", "givenName" : "André-Marie", "sn" : "Ampère", @@ -450,7 +450,7 @@ "teacher6:teacher6" : { "uid" : ["w_rontgen"], "schacHomeOrganization" : "electrical-uni-example.edu", - "eduPersonPrincipalName" : "w_rontgen@electrical-uni-example.edu", + "eduPersonPrincipalName" : "w_rontgen@electrical-uni-example.edu", "cn" : "Wilhelm Conrad Röntgen", "givenName" : "Wilhelm", "sn" : "Röntgen", @@ -463,7 +463,7 @@ "teacher7:teacher7" : { "uid" : ["m_faraday"], "schacHomeOrganization" : "electrical-uni-example.edu", - "eduPersonPrincipalName" : "m_faraday@electrical-uni-example.edu", + "eduPersonPrincipalName" : "m_faraday@electrical-uni-example.edu", "cn" : "Michael Faraday FRS", "givenName" : "Michael", "sn" : "Faraday", @@ -476,7 +476,7 @@ "teacher8:teacher8" : { "uid" : ["n_tesla"], "schacHomeOrganization" : "electrical-uni-example.edu", - "eduPersonPrincipalName" : "n_tesla@electrical-uni-example.edu", + "eduPersonPrincipalName" : "n_tesla@electrical-uni-example.edu", "cn" : "Nikola Tesla", "givenName" : "Nikola", "sn" : "Tesla", @@ -489,7 +489,7 @@ "teacher9:teacher9" : { "uid" : ["teacher9"], "schacHomeOrganization" : "stanford-example.edu", - "eduPersonPrincipalName" : "teacher9@stanford-example.edu", + "eduPersonPrincipalName" : "teacher9@stanford-example.edu", "cn" : "William Henry Gates III", "givenName" : "Bill", "sn" : "Gates", @@ -503,7 +503,7 @@ "teacher10:teacher10" : { "uid" : ["teacher10"], "schacHomeOrganization" : "stanford-example.edu", - "eduPersonPrincipalName" : "teacher10@stanford-example.edu", + "eduPersonPrincipalName" : "teacher10@stanford-example.edu", "cn" : "Steven Paul Jobs", "givenName" : "Steve", "sn" : "Jobs", @@ -513,6 +513,32 @@ "eduPersonScopedAffiliation" : ["employee@stanford-example.edu", "faculty@stanford-example.edu", "member@stanford-example.edu"], "eduPersonEntitlement" : "urn:mace:terena.org:tcs:personal-user-example", "isMemberOf" : "urn:collab:org:aarc-project.eu" + }, + "member1:member1" : { + "uid" : ["member1"], + "schacHomeOrganization" : "diy.surfconext.nl", + "eduPersonPrincipalName" : "member1@diy.surfconext.nl", + "cn" : "Member One", + "givenName" : "Member", + "sn" : "One", + "displayName" : "Member One", + "mail" : "member1@diy.surfconext.nl", + "eduPersonAffiliation" : ["library-walkin", "member"], + "eduPersonScopedAffiliation" : ["library-walkin@diy.surfconext.nl", "member@diy.surfconext.nl"], + "isMemberOf" : "urn:collab:org:aarc-project.eu" + }, + "member2:member2" : { + "uid" : ["member2"], + "schacHomeOrganization" : "diy.surfconext.nl", + "eduPersonPrincipalName" : "member2@diy.surfconext.nl", + "cn" : "Member Two", + "givenName" : "Member", + "sn" : "Two", + "displayName" : "Member Two", + "mail" : "member2@diy.surfconext.nl", + "eduPersonAffiliation" : ["member"], + "eduPersonScopedAffiliation" : ["member@diy.surfconext.nl"], + "isMemberOf" : "urn:collab:org:aarc-project.eu" } } diff --git a/inventory b/inventory index 8adac08..a9a54c4 100644 --- a/inventory +++ b/inventory @@ -1,4 +1,4 @@ -target ansible_host=127.0.0.1 +target ansible_host=145.0.6.67 [idp] target diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 3848e02..03df81d 100755 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -2,12 +2,18 @@ - include_vars: "packages.yml" - include_vars: "repositories.yml" -# add the PPA key for the ondrej PHP version packages -- name: update key cache - apt_key: - keyserver: keyserver.ubuntu.com - id: 4F4EA0AAE5267A6C +- name: ensure that packages are installed + apt: + name: "{{ packages }}" state: present + become: Yes + +# add the PPA key for the ondrej PHP version packages +# - name: update key cache +# apt_key: +# keyserver: keyserver.ubuntu.com +# id: 4F4EA0AAE5267A6C +# state: present - name: perform apt-get update apt: @@ -15,18 +21,12 @@ cache_valid_time: 1 become: Yes -- name: Ensure all necessary repositories are present - apt_repository: - repo: "{{ item }}" - state: present - with_items: "{{ repositories }}" - become: Yes - -- name: ensure that packages are installed - apt: - name: "{{ packages }}" - state: present - become: Yes +# - name: Ensure all necessary repositories are present +# apt_repository: +# repo: "{{ item }}" +# state: present +# with_items: "{{ repositories }}" +# become: Yes - name: Check if FQDN is resolvable command: dig @8.8.8.8 {{ idp_hostname }} diff --git a/roles/common/vars/packages.yml b/roles/common/vars/packages.yml index 486b9c9..8f5e269 100755 --- a/roles/common/vars/packages.yml +++ b/roles/common/vars/packages.yml @@ -1,15 +1,18 @@ --- packages: - apache2 - - certbot + - libapache2-mod-php - libpq-dev - - php5.6 - - libapache2-mod-php5.6 -# - php-fpm - - php5.6-mbstring - - php5.6-xml + - php + - php-mbstring + - php-xml + - php-curl + - composer - postfix - - python-certbot-apache + - certbot + - python3-certbot-apache + - gnupg2 + - bind9-dnsutils packagesfastcgi: - libapache2-mod-fastcgi diff --git a/roles/common/vars/repositories.yml b/roles/common/vars/repositories.yml index 6cfe1d2..09a6598 100755 --- a/roles/common/vars/repositories.yml +++ b/roles/common/vars/repositories.yml @@ -1,11 +1,11 @@ --- -removerepository: - - deb http://security.debian.org/ jessie/updates main contrib non-free - - deb-src http://security.debian.org/ jessie/updates main contrib non-free +# removerepository: + # - deb http://security.debian.org/ jessie/updates main contrib non-free + # - deb-src http://security.debian.org/ jessie/updates main contrib non-free -repositories: - - deb http://ppa.launchpad.net/ondrej/php/ubuntu xenial main - - ppa:certbot/certbot +# repositories: + # - deb http://ppa.launchpad.net/ondrej/php/ubuntu xenial main + # - ppa:certbot/certbot # - deb http://ftp.es.debian.org/debian stable main contrib non-free # - deb-src http://ftp.es.debian.org/debian stable main contrib non-free # - deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free diff --git a/roles/letsencrypt/defaults/main.yml b/roles/letsencrypt/defaults/main.yml index 219a0b6..f4d3144 100644 --- a/roles/letsencrypt/defaults/main.yml +++ b/roles/letsencrypt/defaults/main.yml @@ -12,7 +12,7 @@ letsencrypt_certbot_verbose: true # Pause these services while updating the certificate letsencrypt_pause_services: [] # Force Certificate Reneval -letsencrypt_force_renew: true +letsencrypt_force_renew: false # certbot custom arguments -- see: https://certbot.eff.org/docs/using.html letsencrypt_certbot_args: [] # default arguments passed to certbot diff --git a/roles/letsencrypt/tasks/cert.yaml b/roles/letsencrypt/tasks/cert.yaml index 3ba2c4f..54977d4 100644 --- a/roles/letsencrypt/tasks/cert.yaml +++ b/roles/letsencrypt/tasks/cert.yaml @@ -5,7 +5,7 @@ - set_fact: _letsencrypt_certbot_args="{{ letsencrypt_certbot_args + ['--keep-until-expiring'] }}" when: not letsencrypt_force_renew -- set_fact: _letsencrypt_domains="--domains {{letsencrypt_domain}},www.{{letsencrypt_domain}}" +- set_fact: _letsencrypt_domains="--domains {{letsencrypt_domain}}" when: letsencrypt_request_www - set_fact: _letsencrypt_domains="--domains {{letsencrypt_domain}}" @@ -20,9 +20,9 @@ register: _services_stopped - name: Obtain or renew cert for domain - shell: ./certbot-auto {{_letsencrypt_certbot_combined_args | join(' ')}} 2>&1 + shell: certbot {{_letsencrypt_certbot_combined_args | join(' ')}} 2>&1 args: - chdir: /opt/certbot + # chdir: /opt/certbot executable: /bin/bash ignore_errors: true register: _certbot_command @@ -38,7 +38,7 @@ key_file: "/etc/letsencrypt/live/{{ letsencrypt_domain }}/privkey.pem" certificate_file: "/etc/letsencrypt/live/{{ letsencrypt_domain }}/cert.pem" chain_file: "/etc/letsencrypt/live/{{ letsencrypt_domain }}/fullchain.pem" - when: _signing_successful + # when: _signing_successful - name: Starting paused Services service: name="{{item.item}}" state=started diff --git a/roles/letsencrypt/tasks/client.yaml b/roles/letsencrypt/tasks/client.yaml index dd1d7b1..e2f5360 100644 --- a/roles/letsencrypt/tasks/client.yaml +++ b/roles/letsencrypt/tasks/client.yaml @@ -1,7 +1,7 @@ --- - name: Operating system dependencies - apt: name={{ item }} state=present - with_items: + apt: + name: - build-essential - libssl-dev - libffi-dev @@ -12,6 +12,7 @@ - dialog - libaugeas0 - ca-certificates + state: present - name: Python cryptography module pip: name=cryptography - name: Letsencrypt Python client diff --git a/roles/letsencrypt/tasks/main.yml b/roles/letsencrypt/tasks/main.yml index 05731e7..ad63f2f 100644 --- a/roles/letsencrypt/tasks/main.yml +++ b/roles/letsencrypt/tasks/main.yml @@ -1,3 +1,3 @@ --- -- include: client.yaml +# - include: client.yaml - include: cert.yaml diff --git a/roles/letsencrypt/vars/main.yml b/roles/letsencrypt/vars/main.yml index 1094fab..5753410 100644 --- a/roles/letsencrypt/vars/main.yml +++ b/roles/letsencrypt/vars/main.yml @@ -2,4 +2,4 @@ # vars file for letsencrypt certbot_skip_renewal_message: "Certificate not yet due for renewal; no action taken" -certbot_success_message: "Congratulations!" +certbot_success_message: "Successfully received" diff --git a/roles/simplesaml/defaults/main.yml b/roles/simplesaml/defaults/main.yml index f39a54e..5bff116 100644 --- a/roles/simplesaml/defaults/main.yml +++ b/roles/simplesaml/defaults/main.yml @@ -1,21 +1,25 @@ # Default values for SimpleSamlPHP installation ssp_hostname: www.example.org -ssp_version: 1.14.12 +ssp_version: 2.2.1 +# https://github.com/simplesamlphp/simplesamlphp/releases/download/v2.2.1/simplesamlphp-2.2.1-full.tar.gz ssp_download_base_url: "https://github.com/simplesamlphp/simplesamlphp/releases/download/v{{ ssp_version }}" -ssp_tar_file: simplesamlphp-{{ ssp_version }}.tar.gz +ssp_tar_file: simplesamlphp-{{ ssp_version }}-full.tar.gz ssp_tar_location: /tmp/{{ ssp_tar_file }} ssp_installation_dir: "/var/www" ssp_unarchived_dir: "{{ ssp_installation_dir }}/simplesamlphp-{{ ssp_version }}" ssp_dir: "{{ ssp_installation_dir }}/simplesamlphp" ssp_modules_dir: "{{ ssp_dir }}/modules" ssp_well_known_logins: "{{ ssp_dir }}/config/logins.json" -ssp_base_url_path: "https://{{ ssp_hostname }}" +ssp_base_url_path: "" ssp_cert_dir: "cert" ssp_logging_dir: "log" ssp_data_dir: "data" ssp_temp_dir: "/tmp/simplesaml" -ssp_debug: false -ssp_showerrors: false +ssp_debug: + saml: false + backtraces: true + validatexml: false +ssp_showerrors: true ssp_subject: "/CN={{ ssp_hostname }}" ssp_days_valid: 3650 ssp_key: "{{ ssp_hostname }}.pem" @@ -24,13 +28,10 @@ ssp_auth_admin_password: "changethispassword" #ssp_secretsalt: ssp_technicalcontact_name: Contact ssp_technicalcontact_email: sysop@{{ ssp_hostname }} -ssp_managingcontact_name: Manager -ssp_managingcontact_email: info@{{ ssp_hostname }} ssp_timezone: 'Europe/Amsterdam' -ssp_logging_level: SimpleSAML_Logger::NOTICE +ssp_logging_level: SimpleSAML\Logger::NOTICE ssp_logging_handler: 'syslog' -ssp_session_authtoken_cookiename: SimpleSAMLAuthToken ssp_store_type: phpsession spp_sp_metadata: spp_sp_consumer: -ssp_theme: "default" +ssp_theme: 'default' diff --git a/roles/simplesaml/tasks/main.yml b/roles/simplesaml/tasks/main.yml index d30a47c..b751695 100644 --- a/roles/simplesaml/tasks/main.yml +++ b/roles/simplesaml/tasks/main.yml @@ -1,4 +1,19 @@ --- +- name: Ensure that packages are installed + apt: + name: + - "libapache2-mod-php" + - "php-date" + - "php-json" + - "php-xml" + - "php-mbstring" + - "php-curl" + - "php-zip" + state: "present" + +- name: Enable apache PHP module + shell: a2enmod php8.2 + - name: Install SSP - Download archive get_url: url="{{ ssp_download_base_url }}/{{ ssp_tar_file }}" dest="{{ ssp_tar_location }}" register: ssp_download @@ -9,6 +24,14 @@ - name: Install SSP - Link dir to standard location file: path={{ ssp_dir }} src={{ ssp_unarchived_dir }} state=link force=true +- name: Create ssPHP logs directory + file: + path: "{{ ssp_dir }}/log" + state: directory + owner: www-data + group: www-data + mode: '0755' + - name: Install SSP - Generate salt shell: /usr/bin/tr -c -d '0123456789abcdefghijklmnopqrstuvwxyz' /dev/null;echo register: salt_command @@ -25,88 +48,27 @@ args: creates: "{{ ssp_dir }}/{{ ssp_cert_dir }}/{{ ssp_key }}" -- name: Install SSP - Suffix title to differentiate between various environments - when: ssp_title_suffix is defined - lineinfile: - state: present - firstmatch: yes - insertafter: "data['header'] .= ' - {{ ssp_title_suffix }}';" - path: "{{ ssp_dir }}/templates/includes/header.php" - - name: Install SSP - Remove unused config files and modules file: path="{{ item }}" state=absent with_items: - - "{{ ssp_dir }}/config/acl.php" - - "{{ ssp_dir }}/config/authmemcookie.php" - - "{{ ssp_dir }}/config/cas-ldap.php" - - "{{ ssp_dir }}/config/config-login-auto.php" - - "{{ ssp_dir }}/config/config-login-feide.php" - - "{{ ssp_dir }}/config/ldapmulti.php" - - "{{ ssp_dir }}/config/ldap.php" - - "{{ ssp_dir }}/config/translation.php" - - "{{ ssp_dir }}/metadata/adfs-idp-hosted.php" - - "{{ ssp_dir }}/metadata/adfs-sp-remote.php" - - "{{ ssp_dir }}/metadata/saml20-idp-hosted.php" - - "{{ ssp_dir }}/metadata/saml20-sp-remote.php" - - "{{ ssp_dir }}/metadata/shib13-idp-hosted.php" - - "{{ ssp_dir }}/metadata/shib13-idp-remote.php" - - "{{ ssp_dir }}/metadata/shib13-sp-hosted.php" - - "{{ ssp_dir }}/metadata/shib13-sp-remote.php" - - "{{ ssp_dir }}/metadata/wsfed-idp-remote.php" - - "{{ ssp_dir }}/metadata/wsfed-sp-hosted.php" - - "{{ ssp_modules_dir }}/adfs" - - "{{ ssp_modules_dir }}/aggregator" - - "{{ ssp_modules_dir }}/aggregator2" - - "{{ ssp_modules_dir }}/aselect" - "{{ ssp_modules_dir }}/authorize" - - "{{ ssp_modules_dir }}/authcrypt" - - "{{ ssp_modules_dir }}/authfacebook" - - "{{ ssp_modules_dir }}/authlinkedin" - - "{{ ssp_modules_dir }}/authmyspace" - - "{{ ssp_modules_dir }}/authtwitter" - - "{{ ssp_modules_dir }}/authwindowslive" - - "{{ ssp_modules_dir }}/authX509" - - "{{ ssp_modules_dir }}/authYubiKey" - - "{{ ssp_modules_dir }}/autotest" - - "{{ ssp_modules_dir }}/cas" - - "{{ ssp_modules_dir }}/casserver" - - "{{ ssp_modules_dir }}/cdc" - - "{{ ssp_modules_dir }}/cron" - "{{ ssp_modules_dir }}/consent" - "{{ ssp_modules_dir }}/consentAdmin" - - "{{ ssp_modules_dir }}/consentSimpleAdmin" - "{{ ssp_modules_dir }}/discopower" - - "{{ ssp_modules_dir }}/exampleattributeserver" -# - "{{ ssp_modules_dir }}/exampleauth" - - "{{ ssp_modules_dir }}/expirycheck" - - "{{ ssp_modules_dir }}/InfoCard" - "{{ ssp_modules_dir }}/ldap" - - "{{ ssp_modules_dir }}/logpeek" - - "{{ ssp_modules_dir }}/memcacheMonitor" - - "{{ ssp_modules_dir }}/metaedit" - "{{ ssp_modules_dir }}/metarefresh" - - "{{ ssp_modules_dir }}/modinfo" - "{{ ssp_modules_dir }}/multiauth" - - "{{ ssp_modules_dir }}/negotiate" - - "{{ ssp_modules_dir }}/oauth" - - "{{ ssp_modules_dir }}/openid" - - "{{ ssp_modules_dir }}/openidProvider" - - "{{ ssp_modules_dir }}/papi" -# - "{{ ssp_modules_dir }}/portal" - - "{{ ssp_modules_dir }}/preprodwarning" - "{{ ssp_modules_dir }}/radius" - - "{{ ssp_modules_dir }}/riak" - - "{{ ssp_modules_dir }}/saml2debug" - - "{{ ssp_modules_dir }}/sanitycheck" - - "{{ ssp_modules_dir }}/smartattributes" - - "{{ ssp_modules_dir }}/smartnameattribute" - "{{ ssp_modules_dir }}/sqlauth" - "{{ ssp_modules_dir }}/statistics" - - "{{ ssp_modules_dir }}/themefeidernd" notify: - restart apache +- name: Change ownership of self-signed certificate + file: + path: "{{ ssp_dir }}/{{ ssp_cert_dir }}/{{ ssp_key }}" + owner: www-data + - name: Install SSP - Copy config and metadata template: src={{ item.src }} dest={{ item.dest }} with_items: @@ -114,9 +76,11 @@ - { src: "config/config.php.j2", dest: "{{ ssp_dir }}/config/config.php" } - { src: "group_vars/logins.json", dest: "{{ ssp_well_known_logins }}" } - { src: "metadata/saml20-idp-hosted.php.j2", dest: "{{ ssp_dir }}/metadata/saml20-idp-hosted.php" } + - { src: "metadata/saml20-idp-remote.php.j2", dest: "{{ ssp_dir }}/metadata/saml20-idp-remote.php" } - { src: "metadata/saml20-sp-remote.php.j2", dest: "{{ ssp_dir }}/metadata/saml20-sp-remote.php" } notify: - restart apache - name: Install SSP - Enable example auth file: path="{{ ssp_modules_dir }}/exampleauth/enable" state=touch + diff --git a/roles/simplesaml/templates/config/config.php.j2 b/roles/simplesaml/templates/config/config.php.j2 index 99b0614..f56e032 100644 --- a/roles/simplesaml/templates/config/config.php.j2 +++ b/roles/simplesaml/templates/config/config.php.j2 @@ -1,116 +1,388 @@ '{{ ssp_base_url_path }}/', - 'certdir' => '{{ ssp_cert_dir }}/', - 'loggingdir' => '{{ ssp_logging_dir }}/', - 'datadir' => '{{ ssp_data_dir }}/', /* - * A directory where simpleSAMLphp can save temporary files. + * baseurlpath is a *URL path* (not a filesystem path). + * A valid format for 'baseurlpath' is: + * [(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/] + * + * The full url format is useful if your SimpleSAMLphp setup is hosted behind + * a reverse proxy. In that case you can specify the external url here. + * Specifying the full URL including https: will let SimpleSAMLphp know + * that it runs on HTTPS even if the backend server is plain HTTP. * - * SimpleSAMLphp will attempt to create this directory if it doesn't exist. + * Please note that SimpleSAMLphp will then redirect all queries to the + * external url, no matter where you come from (direct access or via the + * reverse proxy). */ + 'baseurlpath' => '{{ ssp_base_url_path }}/', + + /* + * The 'application' configuration array groups a set configuration options + * relative to an application protected by SimpleSAMLphp. + */ + 'application' => [ + /* + * The 'baseURL' configuration option allows you to specify a protocol, + * host and optionally a port that serves as the canonical base for all + * your application's URLs. This is useful when the environment + * observed in the server differs from the one observed by end users, + * for example, when using a load balancer to offload TLS. + * + * Note that this configuration option does not allow setting a path as + * part of the URL. If your setup involves URL rewriting or any other + * tricks that would result in SimpleSAMLphp observing a URL for your + * application's scripts different than the canonical one, you will + * need to compute the right URLs yourself and pass them dynamically + * to SimpleSAMLphp's API. + */ + //'baseURL' => 'https://example.com', + ], + + /* + * The following settings are *filesystem paths* which define where + * SimpleSAMLphp can find or write the following things: + * - 'loggingdir': Where to write logs. MUST be set to NULL when using a logging + * handler other than `file`. + * - 'datadir': Storage of general data. + * - 'tempdir': Saving temporary files. SimpleSAMLphp will attempt to create + * this directory if it doesn't exist. + * When specified as a relative path, this is relative to the SimpleSAMLphp + * root directory. + */ + 'loggingdir' => '{{ ssp_logging_dir }}/', + 'datadir' => '{{ ssp_data_dir }}/', 'tempdir' => '{{ ssp_temp_dir }}', /* - * If you enable this option, simpleSAMLphp will log all sent and received messages - * to the log file. + * Certificate and key material can be loaded from different possible + * locations. Currently two locations are supported, the local filesystem + * and the database via pdo using the global database configuration. Locations + * are specified by a URL-link prefix before the file name/path or database + * identifier. + */ + + /* To load a certificate or key from the filesystem, it should be specified + * as 'file://' where is either a relative filename or a fully + * qualified path to a file containing the certificate or key in PEM + * format, such as 'cert.pem' or '/path/to/cert.pem'. If the path is + * relative, it will be searched for in the directory defined by the + * 'certdir' parameter below. When 'certdir' is specified as a relative + * path, it will be interpreted as relative to the SimpleSAMLphp root + * directory. Note that locations with no prefix included will be treated + * as file locations. + */ + 'certdir' => '{{ ssp_cert_dir }}/', + + /* To load a certificate or key from the database, it should be specified + * as 'pdo://' where is the identifier in the database table that + * should be matched. While the certificate and key tables are expected to + * be in the simplesaml database, they are not created or managed by + * simplesaml. The following parameters control how the pdo location + * attempts to retrieve certificates and keys from the database: + * + * - 'cert.pdo.table': name of table where certificates are stored + * - 'cert.pdo.keytable': name of table where keys are stored + * - 'cert.pdo.apply_prefix': whether or not to prepend the database.prefix + * parameter to the table names; if you are using + * database.prefix to separate multiple SSP instances + * in the same database but want to share certificate/key + * data between them, set this to false + * - 'cert.pdo.id_column': name of column to use as identifier + * - 'cert.pdo.data_column': name of column where PEM data is stored * - * This option also enables logging of the messages that are encrypted and decrypted. + * Basically, the query executed will be: * - * Note: The messages are logged with the DEBUG log level, so you also need to set - * the 'logging.level' option to LOG_DEBUG. + * SELECT cert.pdo.data_column FROM cert.pdo.table WHERE cert.pdo.id_column = :id + * + * Defaults are shown below, to change them, uncomment the line and update as + * needed */ - 'debug' => {{ ssp_debug }}, + //'cert.pdo.table' => 'certificates', + //'cert.pdo.keytable' => 'private_keys', + //'cert.pdo.apply_prefix' => true, + //'cert.pdo.id_column' => 'id', + //'cert.pdo.data_column' => 'data', - 'showerrors' => {{ ssp_showerrors }}, + /* + * Some information about the technical persons running this installation. + * The email address will be used as the recipient address for error reports, and + * also as the technical contact in generated metadata. + */ + 'technicalcontact_name' => '{{ ssp_technicalcontact_name }}', + 'technicalcontact_email' => '{{ ssp_technicalcontact_email }}', - /** - * Custom error show function called from SimpleSAML_Error_Error::show. - * See docs/simplesamlphp-errorhandling.txt for function code example. + /* + * (Optional) The method by which email is delivered. Defaults to mail which utilizes the + * PHP mail() function. * - * Example: - * 'errors.show_function' => 'sspmod_exmaple_Error_Show::show', + * Valid options are: mail, sendmail and smtp. */ + //'mail.transport.method' => 'smtp', - /** - * This option allows you to enable validation of XML data against its - * schemas. A warning will be written to the log if validation fails. + /* + * Set the transport options for the transport method specified. The valid settings are relative to the + * selected transport method. */ - 'debug.validatexml' => FALSE, + /* + 'mail.transport.options' => [ + 'host' => 'mail.example.org', // required + 'port' => 25, // optional + 'username' => 'user@example.org', // optional: if set, enables smtp authentication + 'password' => 'password', // optional: if set, enables smtp authentication + 'security' => 'tls', // optional: defaults to no smtp security + 'smtpOptions' => [], // optional: passed to stream_context_create when connecting via SMTP + ], + + // sendmail mail transport options + /* + 'mail.transport.options' => [ + 'path' => '/usr/sbin/sendmail' // optional: defaults to php.ini path + ], + */ - /** - * This password must be kept secret, and modified from the default value 123. - * This password will give access to the installation page of simpleSAMLphp with - * metadata listing and diagnostics pages. + /* + * The envelope from address for outgoing emails. + * This should be in a domain that has your application's IP addresses in its SPF record + * to prevent it from being rejected by mail filters. */ - 'auth.adminpassword' => '{{ ssp_auth_admin_password }}', - 'admin.protectindexpage' => TRUE, - 'admin.protectmetadata' => FALSE, + //'sendmail_from' => 'no-reply@example.org', - /** - * This is a secret salt used by simpleSAMLphp when it needs to generate a secure hash + /* + * The timezone of the server. This option should be set to the timezone you want + * SimpleSAMLphp to report the time in. The default is to guess the timezone based + * on your system timezone. + * + * See this page for a list of valid timezones: http://php.net/manual/en/timezones.php + */ + 'timezone' => '{{ ssp_timezone }}', + + + + /********************************** + | SECURITY CONFIGURATION OPTIONS | + **********************************/ + + /* + * This is a secret salt used by SimpleSAMLphp when it needs to generate a secure hash * of a value. It must be changed from its default value to a secret value. The value of * 'secretsalt' can be any valid string of any length. * * A possible way to generate a random salt is by running the following command from a unix shell: - * tr -c -d '0123456789abcdefghijklmnopqrstuvwxyz' /dev/null;echo + * LC_ALL=C tr -c -d '0123456789abcdefghijklmnopqrstuvwxyz' /dev/null;echo */ 'secretsalt' => '{{ ssp_secret_salt }}', /* - * Some information about the technical persons running this installation. - * The email address will be used as the recipient address for error reports, and - * also as the technical contact in generated metadata. + * This password must be kept secret, and modified from the default value 123. + * This password will give access to the installation page of SimpleSAMLphp with + * metadata listing and diagnostics pages. + * You can also put a hash here; run "bin/pwgen.php" to generate one. */ - 'technicalcontact_name' => '{{ ssp_technicalcontact_name }}', - 'technicalcontact_email' => '{{ ssp_technicalcontact_email }}', + 'auth.adminpassword' => '{{ ssp_auth_admin_password }}', - 'managingcontact_name' => '{{ ssp_managingcontact_name }}', - 'managingcontact_email' => '{{ ssp_managingcontact_email }}', + /* + * Set this option to true if you want to require administrator password to access the metadata. + */ + 'admin.protectmetadata' => false, /* - * The timezone of the server. This option should be set to the timezone you want - * simpleSAMLphp to report the time in. The default is to guess the timezone based - * on your system timezone. + * Set this option to false if you don't want SimpleSAMLphp to check for new stable releases when + * visiting the configuration tab in the web interface. + */ + 'admin.checkforupdates' => true, + + /* + * Array of domains that are allowed when generating links or redirects + * to URLs. SimpleSAMLphp will use this option to determine whether to + * to consider a given URL valid or not, but you should always validate + * URLs obtained from the input on your own (i.e. ReturnTo or RelayState + * parameters obtained from the $_REQUEST array). * - * See this page for a list of valid timezones: http://php.net/manual/en/timezones.php + * SimpleSAMLphp will automatically add your own domain (either by checking + * it dynamically, or by using the domain defined in the 'baseurlpath' + * directive, the latter having precedence) to the list of trusted domains, + * in case this option is NOT set to NULL. In that case, you are explicitly + * telling SimpleSAMLphp to verify URLs. + * + * Set to an empty array to disallow ALL redirects or links pointing to + * an external URL other than your own domain. This is the default behaviour. + * + * Set to NULL to disable checking of URLs. DO NOT DO THIS UNLESS YOU KNOW + * WHAT YOU ARE DOING! + * + * Example: + * 'trusted.url.domains' => ['sp.example.com', 'app.example.com'], */ - 'timezone' => '{{ ssp_timezone }}', + 'trusted.url.domains' => [], + + /* + * Enable regular expression matching of trusted.url.domains. + * + * Set to true to treat the values in trusted.url.domains as regular + * expressions. Set to false to do exact string matching. + * + * If enabled, the start and end delimiters ('^' and '$') will be added to + * all regular expressions in trusted.url.domains. + */ + 'trusted.url.regex' => false, + + /* + * Enable secure POST from HTTPS to HTTP. + * + * If you have some SP's on HTTP and IdP is normally on HTTPS, this option + * enables secure POSTing to HTTP endpoint without warning from browser. + * + * For this to work, module.php/core/postredirect.php must be accessible + * also via HTTP on IdP, e.g. if your IdP is on + * https://idp.example.org/ssp/, then + * http://idp.example.org/ssp/module.php/core/postredirect.php must be accessible. + */ + 'enable.http_post' => false, + + /* + * Set the allowed clock skew between encrypting/decrypting assertions + * + * If you have an server that is constantly out of sync, this option + * allows you to adjust the allowed clock-skew. + * + * Allowed range: 180 - 300 + * Defaults to 180. + */ + 'assertion.allowed_clock_skew' => 180, + + + /************************ + | ERRORS AND DEBUGGING | + ************************/ + + /* + * The 'debug' option allows you to control how SimpleSAMLphp behaves in certain + * situations where further action may be taken + * + * It can be left unset, in which case, debugging is switched off for all actions. + * If set, it MUST be an array containing the actions that you want to enable, or + * alternatively a hashed array where the keys are the actions and their + * corresponding values are booleans enabling or disabling each particular action. + * + * SimpleSAMLphp provides some pre-defined actions, though modules could add new + * actions here. Refer to the documentation of every module to learn if they + * allow you to set any more debugging actions. + * + * The pre-defined actions are: + * + * - 'saml': this action controls the logging of SAML messages exchanged with other + * entities. When enabled ('saml' is present in this option, or set to true), all + * SAML messages will be logged, including plaintext versions of encrypted + * messages. + * + * - 'backtraces': this action controls the logging of error backtraces so you + * can debug any possible errors happening in SimpleSAMLphp. + * + * - 'validatexml': this action allows you to validate SAML documents against all + * the relevant XML schemas. SAML 1.1 messages or SAML metadata parsed with + * the XML to SimpleSAMLphp metadata converter or the metaedit module will + * validate the SAML documents if this option is enabled. + * + * If you want to disable debugging completely, unset this option or set it to an + * empty array. + */ + 'debug' => [ + 'saml' => {{ ssp_debug.saml }}, + 'backtraces' => {{ ssp_debug.backtraces }}, + 'validatexml' => {{ ssp_debug.validatexml }}, + ], /* - * Logging. + * When 'showerrors' is enabled, all error messages and stack traces will be output + * to the browser. * - * define the minimum log level to log - * LOG_ERR No statistics, only errors - * LOG_WARNING No statistics, only warnings/errors - * LOG_NOTICE Statistics and errors - * LOG_INFO Verbose logs - * LOG_DEBUG Full debug logs - not reccomended for production + * When 'errorreporting' is enabled, a form will be presented for the user to report + * the error to 'technicalcontact_email'. + */ + 'showerrors' => {{ ssp_showerrors }}, + 'errorreporting' => true, + + /* + * Custom error show function called from SimpleSAML\Error\Error::show. + * See docs/simplesamlphp-errorhandling.md for function code example. + * + * Example: + * 'errors.show_function' => ['SimpleSAML\Module\example\Error', 'show'], + */ + + + /************************** + | LOGGING AND STATISTICS | + **************************/ + + /* + * Define the minimum log level to log. Available levels: + * - SimpleSAML\Logger::ERR No statistics, only errors + * - SimpleSAML\Logger::WARNING No statistics, only warnings/errors + * - SimpleSAML\Logger::NOTICE Statistics and errors + * - SimpleSAML\Logger::INFO Verbose logs + * - SimpleSAML\Logger::DEBUG Full debug logs - not recommended for production * * Choose logging handler. * - * Options: [syslog,file,errorlog] + * Options: [syslog,file,errorlog,stderr] * + * If you set the handler to 'file', the directory specified in loggingdir above + * must exist and be writable for SimpleSAMLphp. If set to something else, set + * loggingdir above to 'null'. */ - 'logging.level' => {{ ssp_logging_level }}, - 'logging.handler' => '{{ ssp_logging_handler }}', + 'logging.level' => {{ ssp_logging_level }}, + 'logging.handler' => '{{ ssp_logging_handler }}', + + /* + * Specify the format of the logs. Its use varies depending on the log handler used (for instance, you cannot + * control here how dates are displayed when using the syslog or errorlog handlers), but in general the options + * are: + * + * - %date{}: the date and time, with its format specified inside the brackets. See the PHP documentation + * of the date() function for more information on the format. If the brackets are omitted, the standard + * format is applied. This can be useful if you just want to control the placement of the date, but don't care + * about the format. + * + * - %process: the name of the SimpleSAMLphp process. Remember you can configure this in the 'logging.processname' + * option below. + * + * - %level: the log level (name or number depending on the handler used). + * + * - %stat: if the log entry is intended for statistical purposes, it will print the string 'STAT ' (bear in mind + * the trailing space). + * + * - %trackid: the track ID, an identifier that allows you to track a single session. + * + * - %srcip: the IP address of the client. If you are behind a proxy, make sure to modify the + * $_SERVER['REMOTE_ADDR'] variable on your code accordingly to the X-Forwarded-For header. + * + * - %msg: the message to be logged. + * + */ + //'logging.format' => '%date{M j H:i:s} %process %level %stat[%trackid] %msg', /* * Choose which facility should be used when logging with syslog. * - * These can be used for filtering the syslog output from simpleSAMLphp into its + * These can be used for filtering the syslog output from SimpleSAMLphp into its * own file by configuring the syslog daemon. * * See the documentation for openlog (http://php.net/manual/en/function.openlog.php) for available @@ -126,39 +398,181 @@ $config = array( */ 'logging.processname' => 'simplesamlphp', - /* Logging: file - Logfilename in the loggingdir from above. + /* + * Logging: file - Logfilename in the loggingdir from above. + */ + 'logging.logfile' => 'simplesamlphp.log', + + /* + * This is an array of outputs. Each output has at least a 'class' option, which + * selects the output. + */ + 'statistics.out' => [ + // Log statistics to the normal log. + /* + [ + 'class' => 'core:Log', + 'level' => 'notice', + ], + */ + // Log statistics to files in a directory. One file per day. + /* + [ + 'class' => 'core:File', + 'directory' => '/var/log/stats', + ], + */ + ], + + + + /*********************** + | PROXY CONFIGURATION | + ***********************/ + + /* + * Proxy to use for retrieving URLs. + * + * Example: + * 'proxy' => 'tcp://proxy.example.com:5100' + */ + 'proxy' => null, + + /* + * Username/password authentication to proxy (Proxy-Authorization: Basic) + * Example: + * 'proxy.auth' = 'myuser:password' */ - 'logging.logfile' => 'simplesamlphp.log', + //'proxy.auth' => 'myuser:password', + /************************** + | DATABASE CONFIGURATION | + **************************/ + + /* + * This database configuration is optional. If you are not using + * core functionality or modules that require a database, you can + * skip this configuration. + */ + + /* + * Database connection string. + * Ensure that you have the required PDO database driver installed + * for your connection string. + */ + 'database.dsn' => 'mysql:host=localhost;dbname=saml', + + /* + * SQL database credentials + */ + 'database.username' => 'simplesamlphp', + 'database.password' => 'secret', + 'database.options' => [], + /* - * Enable + * (Optional) Table prefix + */ + 'database.prefix' => '', + + /* + * (Optional) Driver options + */ + 'database.driver_options' => [], + + /* + * True or false if you would like a persistent database connection + */ + 'database.persistent' => false, + + /* + * Database secondary configuration is optional as well. If you are only + * running a single database server, leave this blank. If you have + * a primary/secondary configuration, you can define as many secondary servers + * as you want here. Secondaries will be picked at random to be queried from. * - * Which functionality in simpleSAMLphp do you want to enable. Normally you would enable only + * Configuration options in the secondary array are exactly the same as the + * options for the primary (shown above) with the exception of the table + * prefix and driver options. + */ + 'database.secondaries' => [ + /* + [ + 'dsn' => 'mysql:host=mysecondary;dbname=saml', + 'username' => 'simplesamlphp', + 'password' => 'secret', + 'persistent' => false, + ], + */ + ], + + + + /************* + | PROTOCOLS | + *************/ + + /* + * Which functionality in SimpleSAMLphp do you want to enable. Normally you would enable only * one of the functionalities below, but in some cases you could run multiple functionalities. * In example when you are setting up a federation bridge. */ - 'enable.saml20-idp' => true, - 'enable.shib13-idp' => false, - 'enable.adfs-idp' => false, - 'enable.wsfed-sp' => false, - 'enable.authmemcookie' => false, + 'enable.saml20-idp' => true, + 'enable.adfs-idp' => false, + + + + /*********** + | MODULES | + ***********/ + + /* + * Configuration for enabling/disabling modules. By default the 'core', 'admin' and 'saml' modules are enabled. + * + * Example: + * + * 'module.enable' => [ + * 'exampleauth' => true, // Setting to TRUE enables. + * 'consent' => false, // Setting to FALSE disables. + * 'core' => null, // Unset or NULL uses default. + * ], + */ + + 'module.enable' => [ + 'exampleauth' => true, + 'core' => true, + 'admin' => true, + 'saml' => true + ], + + + /************************* + | SESSION CONFIGURATION | + *************************/ /* * This value is the duration of the session in seconds. Make sure that the time duration of * cookies both at the SP and the IdP exceeds this duration. */ - 'session.duration' => 8 * (60 * 60), // 8 hours. - 'session.requestcache' => 4 * (60 * 60), // 4 hours + 'session.duration' => 8 * (60 * 60), // 8 hours. /* - * Sets the duration, in seconds, data should be stored in the datastore. As the datastore is used for - * login and logout requests, thid option will control the maximum time these operations can take. + * Sets the duration, in seconds, data should be stored in the datastore. As the data store is used for + * login and logout requests, this option will control the maximum time these operations can take. * The default is 4 hours (4*60*60) seconds, which should be more than enough for these operations. */ 'session.datastore.timeout' => (4 * 60 * 60), // 4 hours + /* + * Sets the duration, in seconds, auth state should be stored. + */ + 'session.state.timeout' => (60 * 60), // 1 hour + + /* + * Option to override the default settings for the session cookie name + */ + 'session.cookie.name' => 'SimpleSAMLSessionID', /* * Expiration time for the session cookie, in seconds. @@ -188,7 +602,7 @@ $config = array( * Example: * 'session.cookie.domain' => '.example.org', */ - 'session.cookie.domain' => NULL, + 'session.cookie.domain' => '', /* * Set the secure flag in the cookie. @@ -197,186 +611,452 @@ $config = array( * through https. If the user can access the service through * both http and https, this must be set to FALSE. */ - 'session.cookie.secure' => TRUE, + 'session.cookie.secure' => true, /* - * Options to override the default settings for php sessions. + * Set the SameSite attribute in the cookie. + * + * You can set this to the strings 'None', 'Lax', or 'Strict' to support + * the RFC6265bis SameSite cookie attribute. If set to null, no SameSite + * attribute will be sent. + * + * A value of "None" is required to properly support cross-domain POST + * requests which are used by different SAML bindings. Because some older + * browsers do not support this value, the canSetSameSiteNone function + * can be called to only set it for compatible browsers. + * + * You must also set the 'session.cookie.secure' value above to true. + * + * Example: + * 'session.cookie.samesite' => 'None', */ - 'session.phpsession.cookiename' => null, - 'session.phpsession.savepath' => null, - 'session.phpsession.httponly' => TRUE, + 'session.cookie.samesite' => $httpUtils->canSetSameSiteNone() ? 'None' : null, /* - * Option to override the default settings for the auth token cookie + * Options to override the default settings for php sessions. */ - 'session.authtoken.cookiename' => '{{ ssp_session_authtoken_cookiename }}', + 'session.phpsession.cookiename' => 'SimpleSAML', + 'session.phpsession.savepath' => null, + 'session.phpsession.httponly' => true, /* - * Languages available and what language is default + * Option to override the default settings for the auth token cookie */ - 'language.available' => array('en'), - 'language.default' => 'en', + 'session.authtoken.cookiename' => 'SimpleSAMLAuthToken', /* - * Extra dictionary for attribute names. - * This can be used to define local attributes. - * - * The format of the parameter is a string with :. + * Options for remember me feature for IdP sessions. Remember me feature + * has to be also implemented in authentication source used. * - * Specifying this option will cause us to look for modules//dictionaries/.definition.json - * The dictionary should look something like: + * Option 'session.cookie.lifetime' should be set to zero (0), i.e. cookie + * expires on browser session if remember me is not checked. * - * { - * "firstattribute": { - * "en": "English name", - * "no": "Norwegian name" - * }, - * "secondattribute": { - * "en": "English name", - * "no": "Norwegian name" - * } - * } + * Session duration ('session.duration' option) should be set according to + * 'session.rememberme.lifetime' option. * - * Note that all attribute names in the dictionary must in lowercase. - * - * Example: 'attributes.extradictionary' => 'ourmodule:ourattributes', + * It's advised to use remember me feature with session checking function + * defined with 'session.check_function' option. */ - 'attributes.extradictionary' => NULL, + 'session.rememberme.enable' => false, + 'session.rememberme.checked' => false, + 'session.rememberme.lifetime' => (14 * 86400), /* - * Which theme directory should be used? + * Custom function for session checking called on session init and loading. + * See docs/simplesamlphp-advancedfeatures.md for function code example. + * + * Example: + * 'session.check_function' => ['\SimpleSAML\Module\example\Util', 'checkSession'], */ - 'theme.use' => '{{ ssp_theme }}', + + /************************** + | MEMCACHE CONFIGURATION | + **************************/ + /* - * Default IdP for WS-Fed. + * Configuration for the 'memcache' session store. This allows you to store + * multiple redundant copies of sessions on different memcache servers. + * + * 'memcache_store.servers' is an array of server groups. Every data + * item will be mirrored in every server group. + * + * Each server group is an array of servers. The data items will be + * load-balanced between all servers in each server group. + * + * Each server is an array of parameters for the server. The following + * options are available: + * - 'hostname': This is the hostname or ip address where the + * memcache server runs. This is the only required option. + * - 'port': This is the port number of the memcache server. If this + * option isn't set, then we will use the 'memcache.default_port' + * ini setting. This is 11211 by default. + * + * When using the "memcache" extension, the following options are also + * supported: + * - 'weight': This sets the weight of this server in this server + * group. http://php.net/manual/en/function.Memcache-addServer.php + * contains more information about the weight option. + * - 'timeout': The timeout for this server. By default, the timeout + * is 3 seconds. + * + * Example of redundant configuration with load balancing: + * This configuration makes it possible to lose both servers in the + * a-group or both servers in the b-group without losing any sessions. + * Note that sessions will be lost if one server is lost from both the + * a-group and the b-group. + * + * 'memcache_store.servers' => [ + * [ + * ['hostname' => 'mc_a1'], + * ['hostname' => 'mc_a2'], + * ], + * [ + * ['hostname' => 'mc_b1'], + * ['hostname' => 'mc_b2'], + * ], + * ], + * + * Example of simple configuration with only one memcache server, + * running on the same computer as the web server: + * Note that all sessions will be lost if the memcache server crashes. + * + * 'memcache_store.servers' => [ + * [ + * ['hostname' => 'localhost'], + * ], + * ], + * + * Additionally, when using the "memcached" extension, unique keys must + * be provided for each group of servers if persistent connections are + * desired. Each server group can also have an "options" indexed array + * with the options desired for the given group: + * + * 'memcache_store.servers' => [ + * 'memcache_group_1' => [ + * 'options' => [ + * \Memcached::OPT_BINARY_PROTOCOL => true, + * \Memcached::OPT_NO_BLOCK => true, + * \Memcached::OPT_TCP_NODELAY => true, + * \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, + * ], + * ['hostname' => '127.0.0.1', 'port' => 11211], + * ['hostname' => '127.0.0.2', 'port' => 11211], + * ], + * + * 'memcache_group_2' => [ + * 'options' => [ + * \Memcached::OPT_BINARY_PROTOCOL => true, + * \Memcached::OPT_NO_BLOCK => true, + * \Memcached::OPT_TCP_NODELAY => true, + * \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, + * ], + * ['hostname' => '127.0.0.3', 'port' => 11211], + * ['hostname' => '127.0.0.4', 'port' => 11211], + * ], + * ], + * */ - 'default-wsfed-idp' => 'urn:federation:pingfederate:localhost', + 'memcache_store.servers' => [ + [ + ['hostname' => 'localhost'], + ], + ], /* - * Whether the discovery service should allow the user to save his choice of IdP. + * This value allows you to set a prefix for memcache-keys. The default + * for this value is 'simpleSAMLphp', which is fine in most cases. + * + * When running multiple instances of SSP on the same host, and more + * than one instance is using memcache, you probably want to assign + * a unique value per instance to this setting to avoid data collision. */ - 'idpdisco.enableremember' => TRUE, - 'idpdisco.rememberchecked' => TRUE, - - // Disco service only accepts entities it knows. - 'idpdisco.validate' => TRUE, - - 'idpdisco.extDiscoveryStorage' => NULL, + 'memcache_store.prefix' => '', /* - * IdP Discovery service look configuration. - * Wether to display a list of idp or to display a dropdown box. For many IdP' a dropdown box - * gives the best use experience. + * This value is the duration data should be stored in memcache. Data + * will be dropped from the memcache servers when this time expires. + * The time will be reset every time the data is written to the + * memcache servers. * - * When using dropdown box a cookie is used to highlight the previously chosen IdP in the dropdown. - * This makes it easier for the user to choose the IdP + * This value should always be larger than the 'session.duration' + * option. Not doing this may result in the session being deleted from + * the memcache servers while it is still in use. * - * Options: [links,dropdown] + * Set this value to 0 if you don't want data to expire. * + * Note: The oldest data will always be deleted if the memcache server + * runs out of storage space. */ - 'idpdisco.layout' => 'dropdown', + 'memcache_store.expires' => 36 * (60 * 60), // 36 hours. + + + + /************************************* + | LANGUAGE AND INTERNATIONALIZATION | + *************************************/ /* - * Whether simpleSAMLphp should sign the response or the assertion in SAML 1.1 authentication - * responses. - * - * The default is to sign the assertion element, but that can be overridden by setting this - * option to TRUE. It can also be overridden on a pr. SP basis by adding an option with the - * same name to the metadata of the SP. + * Languages available, RTL languages, and what language is the default. */ - 'shib13.signresponse' => TRUE, + 'language.available' => [ + 'en', 'no', 'nn', 'se', 'da', 'de', 'sv', 'fi', 'es', 'ca', 'fr', 'it', 'nl', 'lb', + 'cs', 'sk', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt-br', 'tr', 'ja', 'zh', 'zh-tw', + 'ru', 'et', 'he', 'id', 'sr', 'lv', 'ro', 'eu', 'el', 'af', 'zu', 'xh', 'st', + ], + 'language.rtl' => ['ar', 'dv', 'fa', 'ur', 'he'], + 'language.default' => 'en', + /* + * Options to override the default settings for the language parameter + */ + 'language.parameter.name' => 'language', + 'language.parameter.setcookie' => true, + /* + * Options to override the default settings for the language cookie + */ + 'language.cookie.name' => 'language', + 'language.cookie.domain' => '', + 'language.cookie.path' => '/', + 'language.cookie.secure' => true, + 'language.cookie.httponly' => false, + 'language.cookie.lifetime' => (60 * 60 * 24 * 900), + 'language.cookie.samesite' => $httpUtils->canSetSameSiteNone() ? 'None' : null, + + /** + * Custom getLanguage function called from SimpleSAML\Locale\Language::getLanguage(). + * Function should return language code of one of the available languages or NULL. + * See SimpleSAML\Locale\Language::getLanguage() source code for more info. + * + * This option can be used to implement a custom function for determining + * the default language for the user. + * + * Example: + * 'language.get_language_function' => ['\SimpleSAML\Module\example\Template', 'getLanguage'], + */ + + /************** + | APPEARANCE | + **************/ /* - * Authentication processing filters that will be executed for all IdPs - * Both Shibboleth and SAML 2.0 - */ - 'authproc.idp' => array( - /* Enable the authproc filter below to add URN Prefixces to all attributes - 10 => array( - 'class' => 'core:AttributeMap', 'addurnprefix' - ), */ - /* Enable the authproc filter below to automatically generated eduPersonTargetedID. - 20 => 'core:TargetedID', - */ + * Which theme directory should be used? + */ + 'theme.use' => '{{ ssp_theme }}', - // Adopts language from attribute to use in UI - 30 => 'core:LanguageAdaptor', + /* + * Set this option to the text you would like to appear at the header of each page. Set to false if you don't want + * any text to appear in the header. + */ + //'theme.header' => 'SimpleSAMLphp', - /* Add a realm attribute from edupersonprincipalname - 40 => 'core:AttributeRealm', + /** + * A template controller, if any. + * + * Used to intercept certain parts of the template handling, while keeping away unwanted/unexpected hooks. Set + * the 'theme.controller' configuration option to a class that implements the + * \SimpleSAML\XHTML\TemplateControllerInterface interface to use it. */ - 45 => array( - 'class' => 'core:StatisticsWithAttribute', - 'attributename' => 'realm', - 'type' => 'saml20-idp-SSO', - ), + //'theme.controller' => '', - /* When called without parameters, it will fallback to filter attributes ‹the old way› - * by checking the 'attributes' parameter in metadata on IdP hosted and SP remote. + /* + * Templating options + * + * By default, twig templates are not cached. To turn on template caching: + * Set 'template.cache' to an absolute path pointing to a directory that + * SimpleSAMLphp has read and write permissions to. */ - 50 => 'core:AttributeLimit', + //'template.cache' => '', /* - * Search attribute "distinguishedName" for pattern and replaces if found + * Set the 'template.auto_reload' to true if you would like SimpleSAMLphp to + * recompile the templates (when using the template cache) if the templates + * change. If you don't want to check the source templates for every request, + * set it to false. + */ + 'template.auto_reload' => false, - 60 => array( - 'class' => 'core:AttributeAlter', - 'pattern' => '/OU=studerende/', - 'replacement' => 'Student', - 'subject' => 'distinguishedName', - '%replace', - ), + /* + * Set this option to true to indicate that your installation of SimpleSAMLphp + * is running in a production environment. This will affect the way resources + * are used, offering an optimized version when running in production, and an + * easy-to-debug one when not. Set it to false when you are testing or + * developing the software, in which case a banner will be displayed to remind + * users that they're dealing with a non-production instance. + * + * Defaults to true. */ + 'production' => true, /* - * Consent module is enabled (with no permanent storage, using cookies). + * SimpleSAMLphp modules can host static resources which are served through PHP. + * The serving of the resources can be configured through these settings. + */ + 'assets' => [ + /* + * These settings adjust the caching headers that are sent + * when serving static resources. + */ + 'caching' => [ + /* + * Amount of seconds before the resource should be fetched again + */ + 'max_age' => 86400, + /* + * Calculate a checksum of every file and send it to the browser + * This allows the browser to avoid downloading assets again in situations + * where the Last-Modified header cannot be trusted, + * for example in cluster setups + * + * Defaults false + */ + 'etag' => false, + ], + ], - 90 => array( - 'class' => 'consent:Consent', - 'store' => 'consent:Cookie', - 'focus' => 'yes', - 'checked' => TRUE - ), + /** + * Set to a full URL if you want to redirect users that land on SimpleSAMLphp's + * front page to somewhere more useful. If left unset, a basic welcome message + * is shown. */ - // If language is set in Consent module it will be added as an attribute. - 99 => 'core:LanguageAdaptor', -), + //'frontpage.redirect' => 'https://example.com/', + + /********************* + | DISCOVERY SERVICE | + *********************/ + /* - * Authentication processing filters that will be executed for all IdPs - * Both Shibboleth and SAML 2.0 + * Whether the discovery service should allow the user to save his choice of IdP. */ - 'authproc.sp' => array( - /* - 10 => array( - 'class' => 'core:AttributeMap', 'removeurnprefix' - ), - */ + 'idpdisco.enableremember' => true, + 'idpdisco.rememberchecked' => true, - /* When called without parameters, it will fallback to filter attributes ‹the old way› - * by checking the 'attributes' parameter in metadata on SP hosted and IdP remote. + /* + * The disco service only accepts entities it knows. */ - 50 => 'core:AttributeLimit', + 'idpdisco.validate' => true, + + 'idpdisco.extDiscoveryStorage' => null, /* - * Generate the 'group' attribute populated from other variables, including eduPersonAffiliation. + * IdP Discovery service look configuration. + * Whether to display a list of idp or to display a dropdown box. For many IdP' a dropdown box + * gives the best use experience. + * + * When using dropdown box a cookie is used to highlight the previously chosen IdP in the dropdown. + * This makes it easier for the user to choose the IdP + * + * Options: [links,dropdown] */ - 60 => array('class' => 'core:GenerateGroups', 'eduPersonAffiliation'), - // All users will be members of 'users' and 'members' - 61 => array('class' => 'core:AttributeAdd', 'groups' => array('users', 'members')), + 'idpdisco.layout' => 'dropdown', - // Adopts language from attribute to use in UI - 90 => 'core:LanguageAdaptor', -), + /************************************* + | AUTHENTICATION PROCESSING FILTERS | + *************************************/ + + /* + * Authentication processing filters that will be executed for all IdPs + */ + 'authproc.idp' => [ + /* Enable the authproc filter below to add URN prefixes to all attributes + 10 => [ + 'class' => 'core:AttributeMap', 'addurnprefix' + ], + */ + /* Enable the authproc filter below to automatically generated eduPersonTargetedID. + 20 => 'core:TargetedID', + */ + + // Adopts language from attribute to use in UI + 30 => 'core:LanguageAdaptor', + + 45 => [ + 'class' => 'core:StatisticsWithAttribute', + 'attributename' => 'realm', + 'type' => 'saml20-idp-SSO', + ], + + /* When called without parameters, it will fallback to filter attributes 'the old way' + * by checking the 'attributes' parameter in metadata on IdP hosted and SP remote. + */ + 50 => 'core:AttributeLimit', + + /* + * Search attribute "distinguishedName" for pattern and replaces if found + */ + /* + 60 => [ + 'class' => 'core:AttributeAlter', + 'pattern' => '/OU=studerende/', + 'replacement' => 'Student', + 'subject' => 'distinguishedName', + '%replace', + ], + */ + + /* + * Consent module is enabled (with no permanent storage, using cookies). + */ + /* + 90 => [ + 'class' => 'consent:Consent', + 'store' => 'consent:Cookie', + 'focus' => 'yes', + 'checked' => true + ], + */ + // If language is set in Consent module it will be added as an attribute. + 99 => 'core:LanguageAdaptor', + ], + + /* + * Authentication processing filters that will be executed for all SPs + */ + 'authproc.sp' => [ + /* + 10 => [ + 'class' => 'core:AttributeMap', 'removeurnprefix' + ], + */ + + /* + * Generate the 'group' attribute populated from other variables, including eduPersonAffiliation. + 60 => [ + 'class' => 'core:GenerateGroups', 'eduPersonAffiliation' + ], + */ + /* + * All users will be members of 'users' and 'members' + */ + /* + 61 => [ + 'class' => 'core:AttributeAdd', 'groups' => ['users', 'members'] + ], + */ + + // Adopts language from attribute to use in UI + 90 => 'core:LanguageAdaptor', + ], + + + + /************************** + | METADATA CONFIGURATION | + **************************/ + + /* + * This option allows you to specify a directory for your metadata outside of the standard metadata directory + * included in the standard distribution of the software. + */ + 'metadatadir' => 'metadata', /* * This option configures the metadata sources. The metadata sources is given as an array with - * different metadata sources. When searching for metadata, simpleSAMPphp will search through + * different metadata sources. When searching for metadata, SimpleSAMLphp will search through * the array from start to end. * * Each element in the array is an associative array which configures the metadata source. @@ -393,52 +1073,113 @@ $config = array( * This metadata handler parses an XML file with either an EntityDescriptor element or an * EntitiesDescriptor element. The XML file may be stored locally, or (for debugging) on a remote * web server. - * The XML hetadata handler defines the following options: + * The XML metadata handler defines the following options: * - 'type': This is always 'xml'. * - 'file': Path to the XML file with the metadata. - * - 'url': The url to fetch metadata from. THIS IS ONLY FOR DEBUGGING - THERE IS NO CACHING OF THE RESPONSE. + * - 'url': The URL to fetch metadata from. THIS IS ONLY FOR DEBUGGING - THERE IS NO CACHING OF THE RESPONSE. + * + * MDQ metadata handler: + * This metadata handler looks up for the metadata of an entity at the given MDQ server. + * The MDQ metadata handler defines the following options: + * - 'type': This is always 'mdq'. + * - 'server': Base URL of the MDQ server. Mandatory. + * - 'validateCertificate': The certificates file that may be used to sign the metadata. You don't need this + * option if you don't want to validate the signature on the metadata. Optional. + * - 'cachedir': Directory where metadata can be cached. Optional. + * - 'cachelength': Maximum time metadata can be cached, in seconds. Defaults to 24 + * hours (86400 seconds). Optional. * + * PDO metadata handler: + * This metadata handler looks up metadata of an entity stored in a database. + * + * Note: If you are using the PDO metadata handler, you must configure the database + * options in this configuration file. + * + * The PDO metadata handler defines the following options: + * - 'type': This is always 'pdo'. * * Examples: * * This example defines two flatfile sources. One is the default metadata directory, the other - * is a metadata directory with autogenerated metadata files. + * is a metadata directory with auto-generated metadata files. * - * 'metadata.sources' => array( - * array('type' => 'flatfile'), - * array('type' => 'flatfile', 'directory' => 'metadata-generated'), - * ), + * 'metadata.sources' => [ + * ['type' => 'flatfile'], + * ['type' => 'flatfile', 'directory' => 'metadata-generated'], + * ], * * This example defines a flatfile source and an XML source. - * 'metadata.sources' => array( - * array('type' => 'flatfile'), - * array('type' => 'xml', 'file' => 'idp.example.org-idpMeta.xml'), - * ), + * 'metadata.sources' => [ + * ['type' => 'flatfile'], + * ['type' => 'xml', 'file' => 'idp.example.org-idpMeta.xml'], + * ], + * + * This example defines an mdq source. + * 'metadata.sources' => [ + * [ + * 'type' => 'mdq', + * 'server' => 'http://mdq.server.com:8080', + * 'validateCertificate' => [ + * '/var/simplesamlphp/cert/metadata-key.new.crt', + * '/var/simplesamlphp/cert/metadata-key.old.crt' + * ], + * 'cachedir' => '/var/simplesamlphp/mdq-cache', + * 'cachelength' => 86400 + * ] + * ], * + * This example defines an pdo source. + * 'metadata.sources' => [ + * ['type' => 'pdo'] + * ], * * Default: - * 'metadata.sources' => array( - * array('type' => 'flatfile') - * ), + * 'metadata.sources' => [ + * ['type' => 'flatfile'] + * ], */ - 'metadata.sources' => array( - array('type' => 'flatfile'), -), + 'metadata.sources' => [ + ['type' => 'flatfile'], + ], + /* + * Should signing of generated metadata be enabled by default. + * + * Metadata signing can also be enabled for a individual SP or IdP by setting the + * same option in the metadata for the SP or IdP. + */ + 'metadata.sign.enable' => false, /* - * Configure the datastore for simpleSAMLphp. + * The default key & certificate which should be used to sign generated metadata. These + * are files stored in the cert dir. + * These values can be overridden by the options with the same names in the SP or + * IdP metadata. + * + * If these aren't specified here or in the metadata for the SP or IdP, then + * the 'certificate' and 'privatekey' option in the metadata will be used. + * if those aren't set, signing of metadata will fail. + */ + 'metadata.sign.privatekey' => null, + 'metadata.sign.privatekey_pass' => null, + 'metadata.sign.certificate' => null, + + + /**************************** + | DATA STORE CONFIGURATION | + ****************************/ + + /* + * Configure the data store for SimpleSAMLphp. * * - 'phpsession': Limited datastore, which uses the PHP session. * - 'memcache': Key-value datastore, based on memcache. * - 'sql': SQL datastore, using PDO. + * - 'redis': Key-value datastore, based on redis. * * The default datastore is 'phpsession'. - * - * (This option replaces the old 'session.handler'-option.) */ - 'store.type' => '{{ ssp_store_type }}', - + 'store.type' => '{{ ssp_store_type }}', /* * The DSN the sql datastore should connect to. @@ -446,124 +1187,74 @@ $config = array( * See http://www.php.net/manual/en/pdo.drivers.php for the various * syntaxes. */ - 'store.sql.dsn' => 'sqlite:/path/to/sqlitedatabase.sq3', + 'store.sql.dsn' => 'sqlite:/path/to/sqlitedatabase.sq3', /* * The username and password to use when connecting to the database. */ - 'store.sql.username' => NULL, - 'store.sql.password' => NULL, + 'store.sql.username' => null, + 'store.sql.password' => null, /* * The prefix we should use on our tables. */ - 'store.sql.prefix' => 'simpleSAMLphp', - + 'store.sql.prefix' => 'SimpleSAMLphp', /* - * Configuration for the MemcacheStore class. This allows you to store - * multiple redudant copies of sessions on different memcache servers. - * - * 'memcache_store.servers' is an array of server groups. Every data - * item will be mirrored in every server group. - * - * Each server group is an array of servers. The data items will be - * load-balanced between all servers in each server group. - * - * Each server is an array of parameters for the server. The following - * options are available: - * - 'hostname': This is the hostname or ip address where the - * memcache server runs. This is the only required option. - * - 'port': This is the port number of the memcache server. If this - * option isn't set, then we will use the 'memcache.default_port' - * ini setting. This is 11211 by default. - * - 'weight': This sets the weight of this server in this server - * group. http://php.net/manual/en/function.Memcache-addServer.php - * contains more information about the weight option. - * - 'timeout': The timeout for this server. By default, the timeout - * is 3 seconds. - * - * Example of redudant configuration with load balancing: - * This configuration makes it possible to lose both servers in the - * a-group or both servers in the b-group without losing any sessions. - * Note that sessions will be lost if one server is lost from both the - * a-group and the b-group. - * - * 'memcache_store.servers' => array( - * array( - * array('hostname' => 'mc_a1'), - * array('hostname' => 'mc_a2'), - * ), - * array( - * array('hostname' => 'mc_b1'), - * array('hostname' => 'mc_b2'), - * ), - * ), - * - * Example of simple configuration with only one memcache server, - * running on the same computer as the web server: - * Note that all sessions will be lost if the memcache server crashes. - * - * 'memcache_store.servers' => array( - * array( - * array('hostname' => 'localhost'), - * ), - * ), - * + * The driver-options we should pass to the PDO-constructor. */ - 'memcache_store.servers' => array( - array( - array('hostname' => 'localhost'), - ), -), + 'store.sql.options' => [], + /* + * The hostname and port of the Redis datastore instance. + */ + 'store.redis.host' => 'localhost', + 'store.redis.port' => 6379, /* - * This value is the duration data should be stored in memcache. Data - * will be dropped from the memcache servers when this time expires. - * The time will be reset every time the data is written to the - * memcache servers. + * The credentials to use when connecting to Redis. * - * This value should always be larger than the 'session.duration' - * option. Not doing this may result in the session being deleted from - * the memcache servers while it is still in use. - * - * Set this value to 0 if you don't want data to expire. + * If your Redis server is using the legacy password protection (config + * directive "requirepass" in redis.conf) then you should only provide + * a password. * - * Note: The oldest data will always be deleted if the memcache server - * runs out of storage space. + * If your Redis server is using ACL's (which are recommended as of + * Redis 6+) then you should provide both a username and a password. + * See https://redis.io/docs/manual/security/acl/ */ - 'memcache_store.expires' => 36 * (60 * 60), // 36 hours. + 'store.redis.username' => '', + 'store.redis.password' => '', + /* + * The prefix we should use on our Redis datastore. + */ + 'store.redis.prefix' => 'SimpleSAMLphp', /* - * Should signing of generated metadata be enabled by default. - * - * Metadata signing can also be enabled for a individual SP or IdP by setting the - * same option in the metadata for the SP or IdP. + * The master group to use for Redis Sentinel. */ - 'metadata.sign.enable' => FALSE, + 'store.redis.mastergroup' => 'mymaster', /* - * The default key & certificate which should be used to sign generated metadata. These - * are files stored in the cert dir. - * These values can be overridden by the options with the same names in the SP or - * IdP metadata. - * - * If these aren't specified here or in the metadata for the SP or IdP, then - * the 'certificate' and 'privatekey' option in the metadata will be used. - * if those aren't set, signing of metadata will fail. + * The Redis Sentinel hosts. + * Example: + * 'store.redis.sentinels' => [ + * 'tcp://[yoursentinel1]:[port]', + * 'tcp://[yoursentinel2]:[port]', + * 'tcp://[yoursentinel3]:[port] + * ], */ - 'metadata.sign.privatekey' => NULL, - 'metadata.sign.privatekey_pass' => NULL, - 'metadata.sign.certificate' => NULL, + 'store.redis.sentinels' => [], + /********************* + | IdP/SP PROXY MODE | + *********************/ /* - * Proxy to use for retrieving URLs. - * - * Example: - * 'proxy' => 'tcp://proxy.example.com:5100' + * If the IdP in front of SimpleSAMLphp in IdP/SP proxy mode sends + * AuthnContextClassRef, decide whether the AuthnContextClassRef will be + * processed by the IdP/SP proxy or if it will be passed to the SP behind + * the IdP/SP proxy. */ - 'proxy' => NULL, -); + 'proxymode.passAuthnContextClassRef' => false, +]; diff --git a/roles/simplesaml/templates/metadata/saml20-idp-remote.php.j2 b/roles/simplesaml/templates/metadata/saml20-idp-remote.php.j2 new file mode 100644 index 0000000..264e8bc --- /dev/null +++ b/roles/simplesaml/templates/metadata/saml20-idp-remote.php.j2 @@ -0,0 +1,9 @@ + From c6b3ea8ad47b09c6bbb70daaca54ec546d8c89f4 Mon Sep 17 00:00:00 2001 From: Martin van Es Date: Tue, 30 Apr 2024 11:08:20 +0200 Subject: [PATCH 2/4] Update README --- README.md | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index a903979..24760d8 100644 --- a/README.md +++ b/README.md @@ -29,24 +29,15 @@ which is copied from the ansible deployment to its final destination upon provis The original file can be found in the group_vars directory: group_vars/logins.json - + You can add additional users and attributes to this file and (re)provision the IdP. The final product is a single-server installation and not useable in production environments. Setup ===== -The provisioning script was developed for deployment to an Ubuntu Xenial Xerus (16.04 LTS) -installation. Due to the requirement of python for Ansible, the basic installation requires -installation of at least the `python` package: - - sudo apt-get install python - -Instead of installing python, you can use the default `python3` installation by supplying an -ansible configuration - - --extra-vars "ansible_python_interpreter=/usr/bin/python3" - +The provisioning script was developed for deployment to an Debian Bookworm (12) +installation. All other required packages are installed automatically. @@ -88,7 +79,7 @@ dynamically and will change on redeployment. ssp_sp_metadata: "{{ idp_sp }}/authentication/sp/metadata" ssp_sp_consumer: "{{ idp_sp }}/authentication/sp/consume-assertion" ssp_title_suffix: "OpenConext-DIY" - + The 'ssp_title_suffix' option allows differentiating between various default SimpleSaml installations. Comment this option out to disable generating the header suffix. @@ -128,10 +119,6 @@ Then provision the application by running: ansible-playbook -i inventory openconext-diy.yml -or - - ansible-playbook -i inventory openconext-diy.yml --extra-vars "ansible_python_interpreter=/usr/bin/python3" - During provisioning, the roles and tasks will: - try to find out if the target machine has a publicly accessible network address @@ -143,7 +130,7 @@ During provisioning, the roles and tasks will: After provisioning, the metadata is available at: - https://{{ idp_hostname }}/saml2/idp/metadata.php + https://{{ idp_hostname }}/module.php/saml/idp/metadata You can use this link to configure service providers to accept this IdP. @@ -165,13 +152,13 @@ to get the vagrant machine up and running. The `VagrantFile` uses the VirtualBox Docker ====== A basic `Dockerfile` is available to install this IdP on a Docker container. Due to Docker networking -configuration and setup, this installation knows neither hostname nor IP address, so additional -configuration after provisioning is required. +configuration and setup, this installation knows neither hostname nor IP address, so additional +configuration after provisioning is required. The `Dockerfile` mounts the SimpleSAML metadata directory. In the `docker-run` script file, the Docker image is build and the run command mounts the local `docker/metadata` directory to the container, allowing local edits to appear in the container metadata. You can use this as a starting point for -configuring and running your own containers. +configuring and running your own containers. Disclaimer ========== From 4ed318f5b641bca39112e1920edfb0916253d883 Mon Sep 17 00:00:00 2001 From: Martin van Es Date: Tue, 30 Apr 2024 11:09:23 +0200 Subject: [PATCH 3/4] Fix PHP version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 24760d8..77053e4 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ installation. All other required packages are installed automatically. -The installation will use the default PHP version (7.1). You can make this work for other versions +The installation will use the default PHP version (8.2). You can make this work for other versions as well (PHP5.6 for example) by adjusting the package requirements in the `common` role. Some tweaking may apply in the `apache` role as well to get the right modules enabled. From 7d2a1d09db76bc9cff05011d8305f4f0029bf374 Mon Sep 17 00:00:00 2001 From: Martin van Es Date: Tue, 30 Apr 2024 11:29:04 +0200 Subject: [PATCH 4/4] Fix default IdP entityID --- .../simplesaml/templates/metadata/saml20-idp-hosted.php.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/simplesaml/templates/metadata/saml20-idp-hosted.php.j2 b/roles/simplesaml/templates/metadata/saml20-idp-hosted.php.j2 index 6453a23..ba67b55 100644 --- a/roles/simplesaml/templates/metadata/saml20-idp-hosted.php.j2 +++ b/roles/simplesaml/templates/metadata/saml20-idp-hosted.php.j2 @@ -7,7 +7,7 @@ // For compatibility with Shib SPs we need to put the scopes this IdP supports into the metadata. -// These first lines read the logins.json file and process the domain names from the SHO attribute +// These first lines read the logins.json file and process the domain names from the SHO attribute // and add them as scopes to the metadata $fname = realpath("{{ ssp_well_known_logins }}"); $well_known_logins=array(); @@ -26,7 +26,7 @@ foreach($well_known_logins as $key => $val) { $domains = array_unique($domains); -$metadata['__DYNAMIC:1__'] = array( +$metadata['https://{{ ssp_hostname }}/module.php/saml/idp/metadata'] = array( /* * The hostname of the server (VHOST) that will use this SAML entity. * @@ -67,7 +67,7 @@ $metadata['__DYNAMIC:1__'] = array( // Scopes 'scope' => $domains, - + /* Uncomment the following to use the uri NameFormat on attributes. */ //'userid.attribute' => 'eduPersonPrincipalName', 'authproc' => array(