From 4411a0aaf1fe9c3302126cf8c4fe99d01deab09f Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Wed, 11 Aug 2021 09:33:06 +0100 Subject: [PATCH] added ms-autodiscover --- src/core/init/responder.php | 9 +++++ src/public/autoconfig.php | 31 ++++++++++------ src/public/autodiscover.php | 56 +++++++++++++++++------------ src/sample-config/config.sample.ini | 1 + test-entry.sh | 4 +++ test-server.sh | 10 ++++++ 6 files changed, 79 insertions(+), 32 deletions(-) create mode 100755 test-entry.sh create mode 100644 test-server.sh diff --git a/src/core/init/responder.php b/src/core/init/responder.php index 9a49c66..6e2a40f 100644 --- a/src/core/init/responder.php +++ b/src/core/init/responder.php @@ -40,6 +40,9 @@ class Responder { case "mail/config-v1.1.xml": $resp = $this->moz_auto_config(); break; + case "autodiscover": + $resp = $this->ms_autodiscover(); + break; case "none": case "test": case "home": @@ -70,6 +73,12 @@ class Responder { $response->content = "public/autoconfig.php"; return $response; } + private function ms_autodiscover(){ + $response = new Response(); + $response->content_type = "xml"; + $response->content = "public/autodiscover.php"; + return $response; + } private function dummy_response(){ // Generate a dummy response for testing $response = new Response(); diff --git a/src/public/autoconfig.php b/src/public/autoconfig.php index d727289..89bd1c2 100644 --- a/src/public/autoconfig.php +++ b/src/public/autoconfig.php @@ -2,29 +2,40 @@ $conf = Core::$Config["Services"]; $data = Core::get_get_data(); $email_provided = false; -if ($data["path"]) { +$display_name = false; +$emailaddress = false; +if ($data["emailaddress"]) { + $email_address = $data["emailaddress"]; + $display_name = $email_address; + $email_provided = true; +} else if ($data["path"]) { $query = parse_url($data["path"]); - $email = explode("=",$query["query"]); - if ($email[0] == "emailaddress") { - $email = $email[1]; + $email_address = explode("=",$query["query"]); + if ($email_address[0] == "emailaddress") { + $email_address = $email[1]; $email_provided = true; - if (Core::$Config["LogonDomain"]) { - $email = str_ireplace(Core::$Config["Domain"],Core::$Config["LogonDomain"],$email); - } + $display_name = $email_address; + } +} +if ($email_provided) { + if(!Core::$Config["RequireAuthDomain"]) { + $email_address = str_ireplace("@".Core::$Config["Domain"],"",$email_address); + } else if (Core::$Config["LogonDomain"]) { + $email_address = str_ireplace(Core::$Config["Domain"],Core::$Config["LogonDomain"],$email_address); } } ?> "> - + "> - + @@ -34,7 +45,7 @@ if ($data["path"]) { - + diff --git a/src/public/autodiscover.php b/src/public/autodiscover.php index 4c62467..c9f5094 100644 --- a/src/public/autodiscover.php +++ b/src/public/autodiscover.php @@ -1,30 +1,42 @@ +(.*?)\<\/EMailAddress\>/", $data, $matches); +echo ''; ?> email settings - - IMAP - server.hostname.com - 993 - off - - off - on - on - - - SMTP - server.hostname.com - 587 - off - - off - TLS - on - off - off - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/sample-config/config.sample.ini b/src/sample-config/config.sample.ini index b89f781..a163648 100644 --- a/src/sample-config/config.sample.ini +++ b/src/sample-config/config.sample.ini @@ -4,6 +4,7 @@ ; Set the base domain for use with this service Domain = example.com LogonDomain = example.local +RequireAuthDomain = false ; Admin User configuration ; not in use yet diff --git a/test-entry.sh b/test-entry.sh new file mode 100755 index 0000000..50df86c --- /dev/null +++ b/test-entry.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +a2enmod rewrite +service apache2 stop +exec apache2-foreground diff --git a/test-server.sh b/test-server.sh new file mode 100644 index 0000000..98b0efe --- /dev/null +++ b/test-server.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +podman run --name davdiscover-test \ + --rm \ + -p "8010:80" \ + -v ./src:/var/www/html/ \ + -v ./config:/var/www/html/config \ + -v ./test-entry.sh:/test-entry.sh \ + --entrypoint "/bin/bash" \ + php:7.4-apache \ + /test-entry.sh