Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
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 = "/"
  • Loading branch information
Pavlo-Lyha authored Jun 15, 2023
1 parent 1bb65aa commit a9f3bae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
6 changes: 5 additions & 1 deletion duo_auth.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
14 changes: 7 additions & 7 deletions duo_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"])) {
Expand All @@ -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;

}
Expand All @@ -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();
Expand All @@ -74,7 +74,7 @@ function _main_handler_process_() {
}
session_destroy();

header("Location: /");
header("Location: {$config["rc_path"]}");
exit;

}
Expand Down Expand Up @@ -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 {}
Expand All @@ -127,4 +127,4 @@ private function ipaddr($ip, $cidr) {

}

?>
?>
10 changes: 5 additions & 5 deletions your_page_name_redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:"];
Expand All @@ -40,7 +40,7 @@
}
session_destroy();

header("Location: /");
header("Location: {$config["rc_path"]}");
exit;

} else {
Expand All @@ -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();
Expand All @@ -64,10 +64,10 @@
}
session_destroy();

header("Location: /");
header("Location: {$config["rc_path"]}");
exit;
}

}

?>
?>

0 comments on commit a9f3bae

Please sign in to comment.