[Web] add ldap idp
This commit is contained in:
@@ -4,6 +4,7 @@ if ($iam_provider){
|
||||
if (isset($_GET['iam_sso'])){
|
||||
// redirect for sso
|
||||
$redirect_uri = identity_provider('get-redirect', array('iam_provider' => $iam_provider));
|
||||
$redirect_uri = !empty($redirect_uri) ? $redirect_uri : '/';
|
||||
header('Location: ' . $redirect_uri);
|
||||
die();
|
||||
}
|
||||
@@ -12,9 +13,9 @@ if ($iam_provider){
|
||||
$isRefreshed = identity_provider('refresh-token', array('iam_provider' => $iam_provider));
|
||||
|
||||
if (!$isRefreshed){
|
||||
// Session could not be refreshed, clear and redirect to provider
|
||||
clear_session();
|
||||
// Session could not be refreshed, redirect to provider
|
||||
$redirect_uri = identity_provider('get-redirect', array('iam_provider' => $iam_provider));
|
||||
$redirect_uri = !empty($redirect_uri) ? $redirect_uri : '/';
|
||||
header('Location: ' . $redirect_uri);
|
||||
die();
|
||||
}
|
||||
@@ -39,13 +40,16 @@ if (!empty($_GET['sso_token'])) {
|
||||
|
||||
if (isset($_POST["verify_tfa_login"])) {
|
||||
if (verify_tfa_login($_SESSION['pending_mailcow_cc_username'], $_POST)) {
|
||||
$_SESSION['mailcow_cc_username'] = $_SESSION['pending_mailcow_cc_username'];
|
||||
$_SESSION['mailcow_cc_role'] = $_SESSION['pending_mailcow_cc_role'];
|
||||
unset($_SESSION['pending_mailcow_cc_username']);
|
||||
unset($_SESSION['pending_mailcow_cc_role']);
|
||||
unset($_SESSION['pending_tfa_methods']);
|
||||
|
||||
header("Location: /user");
|
||||
set_user_loggedin_session($_SESSION['pending_mailcow_cc_username']);
|
||||
$user_details = mailbox("get", "mailbox_details", $_SESSION['mailcow_cc_username']);
|
||||
$is_dual = (!empty($_SESSION["dual-login"]["username"])) ? true : false;
|
||||
if (intval($user_details['attributes']['sogo_access']) == 1 && !$is_dual) {
|
||||
header("Location: /SOGo/so/{$_SESSION['mailcow_cc_username']}");
|
||||
die();
|
||||
} else {
|
||||
header("Location: /user");
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
unset($_SESSION['pending_mailcow_cc_username']);
|
||||
unset($_SESSION['pending_mailcow_cc_role']);
|
||||
@@ -70,10 +74,10 @@ if (isset($_POST["quick_delete"])) {
|
||||
}
|
||||
|
||||
if (isset($_POST["login_user"]) && isset($_POST["pass_user"])) {
|
||||
$login_user = strtolower(trim($_POST["login_user"]));
|
||||
$as = check_login($login_user, $_POST["pass_user"]);
|
||||
$login_user = strtolower(trim($_POST["login_user"]));
|
||||
$as = check_login($login_user, $_POST["pass_user"]);
|
||||
|
||||
if ($as == "admin") {
|
||||
if ($as == "admin") {
|
||||
$_SESSION['mailcow_cc_username'] = $login_user;
|
||||
$_SESSION['mailcow_cc_role'] = "admin";
|
||||
header("Location: /admin");
|
||||
@@ -84,19 +88,27 @@ if (isset($_POST["login_user"]) && isset($_POST["pass_user"])) {
|
||||
header("Location: /mailbox");
|
||||
}
|
||||
elseif ($as == "user") {
|
||||
$_SESSION['mailcow_cc_username'] = $login_user;
|
||||
$_SESSION['mailcow_cc_role'] = "user";
|
||||
$http_parameters = explode('&', $_SESSION['index_query_string']);
|
||||
unset($_SESSION['index_query_string']);
|
||||
if (in_array('mobileconfig', $http_parameters)) {
|
||||
if (in_array('only_email', $http_parameters)) {
|
||||
header("Location: /mobileconfig.php?only_email");
|
||||
die();
|
||||
}
|
||||
header("Location: /mobileconfig.php");
|
||||
set_user_loggedin_session($login_user);
|
||||
$http_parameters = explode('&', $_SESSION['index_query_string']);
|
||||
unset($_SESSION['index_query_string']);
|
||||
if (in_array('mobileconfig', $http_parameters)) {
|
||||
if (in_array('only_email', $http_parameters)) {
|
||||
header("Location: /mobileconfig.php?only_email");
|
||||
die();
|
||||
}
|
||||
header("Location: /user");
|
||||
header("Location: /mobileconfig.php");
|
||||
die();
|
||||
}
|
||||
|
||||
$user_details = mailbox("get", "mailbox_details", $login_user);
|
||||
$is_dual = (!empty($_SESSION["dual-login"]["username"])) ? true : false;
|
||||
if (intval($user_details['attributes']['sogo_access']) == 1 && !$is_dual) {
|
||||
header("Location: /SOGo/so/{$login_user}");
|
||||
die();
|
||||
} else {
|
||||
header("Location: /user");
|
||||
die();
|
||||
}
|
||||
}
|
||||
elseif ($as != "pending") {
|
||||
unset($_SESSION['pending_mailcow_cc_username']);
|
||||
|
||||
Reference in New Issue
Block a user