From d43dd7bf103251a5c0c8110a2aa4491444355c47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@sedlistka.cz>
Date: Wed, 11 Dec 2019 20:46:19 +0100
Subject: [PATCH] Znema SP entity ID

---
 entrypoint.sh        |  7 +++----
 mod_auth_mellon.conf | 10 +++++++---
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index 3b2e712..fbabcab 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -2,7 +2,6 @@
 # Entrypoint for Docker Container
 
 HOST=${HOST:-'dotazniky.pirati.cz'}
-SP_ID=${SP_ID:-'dotazniky'}
 IDP_METADATA=${IDP_METADATA:-'https://auth.pirati.cz/auth/realms/pirati/protocol/saml/descriptor'}
 
 DB_TYPE=${DB_TYPE:-'pgsql'}
@@ -31,14 +30,14 @@ if [ ! -f /etc/apache2/saml2/idp.xml ]; then
 fi
 
 # Create mod_auth_mellon service provider config
-if [ ! -f /etc/apache2/saml2/${SP_ID}.xml ]; then
+if [ ! -f /etc/apache2/saml2/${HOST}.xml ]; then
     pushd /etc/apache2/saml2
      echo -e "Generating new service provider certificate.\n\n" 
-     /usr/sbin/mellon_create_metadata ${SP_ID} https://${HOST}/mellon
+     /usr/sbin/mellon_create_metadata https://${HOST}/mellon/metadata https://${HOST}/mellon
     popd
 fi
 
-sed -i "s/{{SP_ID}}/${SP_ID}/g" /etc/apache2/conf-enabled/mod_auth_mellon.conf
+sed -i "s/{{SP_ID}}/${HOST}/g" /etc/apache2/conf-enabled/mod_auth_mellon.conf
 
 # Check if database is available
 if [ -z "$DB_SOCK" ]; then
diff --git a/mod_auth_mellon.conf b/mod_auth_mellon.conf
index cda2562..1bf0425 100644
--- a/mod_auth_mellon.conf
+++ b/mod_auth_mellon.conf
@@ -1,10 +1,14 @@
-<Location /admin >
- AuthType Mellon
- MellonEnable auth
+<Location / >
+ MellonEnable info
  MellonEndpointPath /mellon
  MellonSPPrivateKeyFile /etc/apache2/saml2/{{SP_ID}}.key
  MellonSPCertFile       /etc/apache2/saml2/{{SP_ID}}.cert
  MellonSPMetadataFile   /etc/apache2/saml2/{{SP_ID}}.xml
  MellonIdPMetadataFile  /etc/apache2/saml2/idp.xml
+</Location>
+
+<Location /admin >
+ AuthType Mellon
+ MellonEnable auth
  Require valid-user
 </Location>
-- 
GitLab