From a9f3bae169ce26bb67e1ae2c5f009181966596a9 Mon Sep 17 00:00:00 2001 From: Pavlo-Lyha <135230440+Pavlo-Lyha@users.noreply.github.com> Date: Thu, 15 Jun 2023 20:02:00 +0300 Subject: [PATCH] Add files via upload Add new key "rc_path" in duo.conf for simple configuration web-folder path for your RC installation. [rc_path] ;you must indicate URI web-server path without FQDN to your web folder RC installation, for example - rc_path = "/" if web-folder is root, or rc_path = "/rc/" if your installation sub-web-folder, virtual folder or alias. rc_path = "/" --- duo_auth.conf | 6 +++++- duo_auth.php | 14 +++++++------- your_page_name_redirect.php | 10 +++++----- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/duo_auth.conf b/duo_auth.conf index 3b6abaa..7c7ba5d 100644 --- a/duo_auth.conf +++ b/duo_auth.conf @@ -25,6 +25,10 @@ http_proxy = "" ;or to "Fail Closed" and prohibit the login completely). failmode = "closed" +[rc_path] +;you must indicate URI web-server path without FQDN to your web folder RC installation, for example - rc_path = "/" if web-folder is root, or rc_path = "/rc/" if your installation sub-web-folder, virtual folder or alias. +rc_path = "/" + [bypass_username] ;username[] value must be same identical username value in username field in login page form depends on your deployment scenario and your own IMAP mail system configuration @@ -45,4 +49,4 @@ failmode = "closed" ;ipaddr[] = "192.168.100.100" ;ipaddr[] = "192.168.100.100/32" ;ipaddr[] = "192.168.0.0/24" -;ipaddr[] = "192.168.0.0/28" +;ipaddr[] = "192.168.0.0/28" \ No newline at end of file diff --git a/duo_auth.php b/duo_auth.php index bedfafd..7b3fb18 100644 --- a/duo_auth.php +++ b/duo_auth.php @@ -6,7 +6,7 @@ ########## # define new class plugin inside RoundCube Plugin App environment (RoundCube API SDK) - class duo_auth extends rcube_plugin { + class duo_sdk extends rcube_plugin { ########## # define hook's set inside calling current RoundCube instance (fully initialize RoundCube proccess instance) @@ -30,7 +30,7 @@ function _main_handler_process_() { if (isset($config["username"]) && in_array($username, $config["username"])) { - header("Location: /?_task=mail"); + header("Location: {$config["rc_path"]}?_task=mail"); exit; } elseif (isset($config["ipaddr"])) { @@ -39,7 +39,7 @@ function _main_handler_process_() { if ($this->ipaddr($_SERVER['REMOTE_ADDR'], $ipaddr)) { - header("Location: /?_task=mail"); + header("Location: {$config["rc_path"]}?_task=mail"); exit; } @@ -63,7 +63,7 @@ function _main_handler_process_() { $e->getMessage(); if ($duo_failmode == "open") { - header("Location: /?_task=mail"); + header("Location: {$config["rc_path"]}?_task=mail"); exit; } else { $_SESSION = array(); @@ -74,7 +74,7 @@ function _main_handler_process_() { } session_destroy(); - header("Location: /"); + header("Location: {$config["rc_path"]}"); exit; } @@ -104,7 +104,7 @@ function _blocking_access_() { if (isset($_SESSION["_duo_auth_"])) { - header("Location: /your_page_name_blocking_access_while_2FA_not_approved.htm"); + header("Location: {$config["rc_path"]}your_page_name_blocking_access_while_2FA_not_approved.htm"); exit; } else {} @@ -127,4 +127,4 @@ private function ipaddr($ip, $cidr) { } -?> +?> \ No newline at end of file diff --git a/your_page_name_redirect.php b/your_page_name_redirect.php index cf77982..84eff64 100644 --- a/your_page_name_redirect.php +++ b/your_page_name_redirect.php @@ -25,7 +25,7 @@ # define attribute user Duo Web v4 SDK session state $state = $_GET["state"]; $code = $_GET["duo_code"]; - session_name("roundcube_sessid"); + session_name("your_session_name"); session_start(); $saved_state = $_SESSION["_duo_auth_"]["state:"]; $username = $_SESSION["_duo_auth_"]["username:"]; @@ -40,7 +40,7 @@ } session_destroy(); - header("Location: /"); + header("Location: {$config["rc_path"]}"); exit; } else { @@ -53,7 +53,7 @@ $result = json_decode($result, true); if ($result["auth_context"]["result"] == 'success') { - header("Location: /?_task=mail"); + header("Location: {$config["rc_path"]}?_task=mail"); exit; } else { $_SESSION = array(); @@ -64,10 +64,10 @@ } session_destroy(); - header("Location: /"); + header("Location: {$config["rc_path"]}"); exit; } } -?> +?> \ No newline at end of file