TASK-207 Merge for ldap and ldapAdvanced
This commit is contained in:
162
workflow/engine/methods/authSources/authSourcesProxy.php
Normal file
162
workflow/engine/methods/authSources/authSourcesProxy.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
use ProcessMaker\Model\RbacAuthenticationSource;
|
||||
require_once 'classes/AuthSources.php';
|
||||
try {
|
||||
if (isset($_REQUEST['action']) === false) {
|
||||
throw new Exception('No action was sent');
|
||||
}
|
||||
|
||||
if (isset($_SESSION['USER_LOGGED']) === false) {
|
||||
throw new Exception('There is no logged in user');
|
||||
}
|
||||
|
||||
$action = $_REQUEST['action'];
|
||||
$userUid = $_SESSION['USER_LOGGED'];
|
||||
$responseProxy = ['success' => true];
|
||||
|
||||
switch ($action) {
|
||||
case 'authSourcesList':
|
||||
$start = $_REQUEST['start'] ?? 0;
|
||||
$limit = $_REQUEST['limit'] ?? $limit_size;
|
||||
$filter = $_REQUEST['textFilter'] ?? '';
|
||||
$orderBy = $_REQUEST['orderBy'] ?? '';
|
||||
$ascending = $_REQUEST['ascending'] ?? '';
|
||||
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->getListAuthSources($userUid, $start, $limit, $orderBy, $ascending, $filter);
|
||||
break;
|
||||
case 'authSourcesDelete':
|
||||
if (!isset($_REQUEST['auth_uid'])) {
|
||||
throw new Exception('No auth source UID was sent');
|
||||
}
|
||||
$authSourceUid = $_REQUEST['auth_uid'];
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->removeAuthSource($authSourceUid);
|
||||
break;
|
||||
case 'authSourcesVerifyName':
|
||||
if (empty($_REQUEST['AUTH_SOURCE_NAME'])) {
|
||||
throw new Exception('No auth source UID was sent');
|
||||
}
|
||||
|
||||
$authSourceName = $_REQUEST['AUTH_SOURCE_NAME'];
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->verifyAuthSourceName($authSourceName);
|
||||
break;
|
||||
case 'authSourcesTestConnection':
|
||||
if ($_REQUEST['AUTH_ANONYMOUS'] == '1') {
|
||||
$_REQUEST['AUTH_SOURCE_SEARCH_USER'] = '';
|
||||
$_REQUEST['AUTH_SOURCE_PASSWORD'] = '';
|
||||
}
|
||||
|
||||
$authSourceData = $_REQUEST;
|
||||
$authSourceData['AUTH_SOURCE_VERSION'] = 3;
|
||||
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->testConnection($authSourceData);
|
||||
break;
|
||||
case 'authSourcesSave':
|
||||
$temporalData = $_REQUEST;
|
||||
|
||||
if (isset($temporalData['AUTH_SOURCE_SHOWGRID-checkbox'])) {
|
||||
if ($temporalData['AUTH_SOURCE_SHOWGRID-checkbox'] == 'on') {
|
||||
$temporalData['AUTH_SOURCE_SHOWGRID'] = 'on';
|
||||
$attributes = G::json_decode($temporalData['AUTH_SOURCE_GRID_TEXT']);
|
||||
$con = 1;
|
||||
foreach ($attributes as $value) {
|
||||
$temporalData['AUTH_SOURCE_GRID_ATTRIBUTE'][$con] = (array)$value;
|
||||
$con++;
|
||||
}
|
||||
}
|
||||
unset($temporalData['AUTH_SOURCE_SHOWGRID-checkbox']);
|
||||
}
|
||||
|
||||
if ($temporalData['AUTH_ANONYMOUS'] == '1') {
|
||||
$temporalData['AUTH_SOURCE_SEARCH_USER'] = '';
|
||||
$temporalData['AUTH_SOURCE_PASSWORD'] = '';
|
||||
}
|
||||
|
||||
unset($temporalData['AUTH_SOURCE_GRID_TEXT']);
|
||||
unset($temporalData['DELETE1']);
|
||||
unset($temporalData['DELETE2']);
|
||||
unset($temporalData['AUTH_SOURCE_ATTRIBUTE_IDS']);
|
||||
unset($temporalData['AUTH_SOURCE_SHOWGRID_FLAG']);
|
||||
unset($temporalData['AUTH_SOURCE_GRID_TEXT']);
|
||||
|
||||
$commonFields = array('AUTH_SOURCE_UID', 'AUTH_SOURCE_NAME', 'AUTH_SOURCE_PROVIDER', 'AUTH_SOURCE_SERVER_NAME', 'AUTH_SOURCE_PORT', 'AUTH_SOURCE_ENABLED_TLS', 'AUTH_ANONYMOUS', 'AUTH_SOURCE_SEARCH_USER', 'AUTH_SOURCE_PASSWORD', 'AUTH_SOURCE_VERSION', 'AUTH_SOURCE_BASE_DN', 'AUTH_SOURCE_OBJECT_CLASSES', 'AUTH_SOURCE_ATTRIBUTES');
|
||||
|
||||
$authSourceData = $authSourceExtraData = array();
|
||||
foreach ($temporalData as $sField => $sValue) {
|
||||
if (in_array($sField, $commonFields)) {
|
||||
$authSourceData[$sField] = $sValue;
|
||||
} else {
|
||||
$authSourceExtraData[$sField] = $sValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($authSourceExtraData['AUTH_SOURCE_SHOWGRID']) || $authSourceExtraData['AUTH_SOURCE_SHOWGRID'] == 'off') {
|
||||
unset($authSourceExtraData['AUTH_SOURCE_GRID_ATTRIBUTE']);
|
||||
unset($authSourceExtraData['AUTH_SOURCE_SHOWGRID']);
|
||||
}
|
||||
|
||||
$authSourceData['AUTH_SOURCE_DATA'] = $authSourceExtraData;
|
||||
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->saveAuthSource($authSourceData);
|
||||
break;
|
||||
case 'authSourcesImportSearchUsers':
|
||||
if (!isset($_REQUEST['sUID'])) {
|
||||
throw new Exception('No auth source UID was sent');
|
||||
}
|
||||
|
||||
$authSourceUid = $_POST['sUID'];
|
||||
$filters = [
|
||||
'start'=> $_POST['start'] ?? 0,
|
||||
'limit'=> $_POST['limit'] ?? ($_POST["pageSize"] ?? 10),
|
||||
'text'=> $_POST['sKeyword'] ?? ''
|
||||
];
|
||||
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->searchUsers($authSourceUid, $filters);
|
||||
break;
|
||||
case 'authSourcesImportUsers':
|
||||
if (!isset($_REQUEST['UsersImport'])) {
|
||||
throw new Exception('There are no users to import');
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['AUTH_SOURCE_UID'])) {
|
||||
throw new Exception('The auth source UID was not sent');
|
||||
}
|
||||
|
||||
$authSourceUid = $_REQUEST['AUTH_SOURCE_UID'];
|
||||
$usersImport = $_REQUEST['UsersImport'];
|
||||
$usersImport = json_decode($usersImport, true);
|
||||
|
||||
$authSources = new AuthSources();
|
||||
$responseProxy = $authSources->importUsers($authSourceUid, $usersImport);
|
||||
break;
|
||||
case 'authSourcesImportLoadDepartment':
|
||||
$responseProxy['success'] = true;
|
||||
break;
|
||||
case 'authSourcesImportSaveDepartment':
|
||||
$responseProxy['success'] = true;
|
||||
break;
|
||||
case 'authSourcesImportLoadGroup':
|
||||
$responseProxy['success'] = true;
|
||||
break;
|
||||
case 'authSourcesImportSaveGroup':
|
||||
$responseProxy['success'] = true;
|
||||
break;
|
||||
default:
|
||||
throw new Exception('The action "' . $action . '" is not allowed');
|
||||
break;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($responseProxy, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
} catch (Exception $exception) {
|
||||
$responseProxy['success'] = false;
|
||||
$responseProxy['message'] = $exception->getMessage();
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($responseProxy, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
@@ -306,6 +306,7 @@ switch ($function) {
|
||||
// asign the FirstName and LastName variables
|
||||
// add replace to change D*Souza to D'Souza by krlos
|
||||
$aData['USR_FIRSTNAME'] = str_replace("*", "'", $aUser['sFirstname']);
|
||||
$aData['USR_FIRSTNAME'] = ($aData['USR_FIRSTNAME'] == '') ? $aData['USR_USERNAME'] : $aData['USR_FIRSTNAME'];
|
||||
$aData['USR_LASTNAME'] = str_replace("*", "'", $aUser['sLastname']);
|
||||
$aData['USR_EMAIL'] = $aUser['sEmail'];
|
||||
$aData['USR_DUE_DATE'] = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y') + 2));
|
||||
@@ -325,16 +326,18 @@ switch ($function) {
|
||||
}
|
||||
$aData['USR_AUTH_USER_DN'] = $aUser['sDN'];
|
||||
|
||||
$usrRole = 'PROCESSMAKER_OPERATOR';
|
||||
$usrRole = 'LURANA_OPERATOR';
|
||||
if (!empty($aFields['AUTH_SOURCE_DATA']['USR_ROLE'])) {
|
||||
$usrRole = $aFields['AUTH_SOURCE_DATA']['USR_ROLE'];
|
||||
//$usrRole = $aFields['AUTH_SOURCE_DATA']['USR_ROLE'];
|
||||
}
|
||||
|
||||
try {
|
||||
//dd($aData, $usrRole, $aFields['AUTH_SOURCE_NAME']);
|
||||
$sUserUID = $RBAC->createUser($aData, $usrRole, $aFields['AUTH_SOURCE_NAME']);
|
||||
$usersCreated .= $aData['USR_USERNAME'] . ' ';
|
||||
$countUsers++;
|
||||
} catch (Exception $oError) {
|
||||
dd($oError);
|
||||
$G_PUBLISH = new Publisher();
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => $oError->getMessage()));
|
||||
G::RenderPage("publish", "blank");
|
||||
@@ -397,7 +400,7 @@ switch ($function) {
|
||||
|
||||
$resultLDAPStartTLS = true;
|
||||
$ldapcnn = $ldapAdvanced->ldapConnection($arrayAuthenticationSourceData, $resultLDAPStartTLS);
|
||||
|
||||
|
||||
//Response
|
||||
$response["status"] = "OK";
|
||||
if ($resultLDAPStartTLS === false) {
|
||||
|
||||
@@ -102,16 +102,17 @@
|
||||
|
||||
saveNewConnection(form) {
|
||||
let formData = this.$refs.newConnection.formToFormData(form);
|
||||
axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapSave", formData)
|
||||
.then(response => {
|
||||
response;
|
||||
this.$refs.authenticationSources.refresh();
|
||||
})
|
||||
.catch(error => {
|
||||
error;
|
||||
})
|
||||
.finally(() => {
|
||||
});
|
||||
//axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapSave", formData)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy?action=authSourcesSave", formData)
|
||||
.then(response => {
|
||||
response;
|
||||
this.$refs.authenticationSources.refresh();
|
||||
})
|
||||
.catch(error => {
|
||||
error;
|
||||
})
|
||||
.finally(() => {
|
||||
});
|
||||
this.showView('authenticationSources');
|
||||
},
|
||||
|
||||
|
||||
@@ -98,7 +98,8 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
baseUrl: this.$root.baseUrl() + "authSources/authSources_Ajax?action=authSourcesList",
|
||||
//baseUrl: this.$root.baseUrl() + "authSources/authSources_Ajax?action=authSourcesList",
|
||||
baseUrl: this.$root.baseUrl() + "authSources/authSourcesProxy?action=authSourcesList",
|
||||
columns: [
|
||||
"AUTH_SOURCE_NAME",
|
||||
"AUTH_SOURCE_PROVIDER",
|
||||
@@ -193,9 +194,11 @@
|
||||
return;
|
||||
}
|
||||
let formData = new FormData();
|
||||
formData.append("action", "deleteAuthSource");
|
||||
//formData.append("action", "deleteAuthSource");
|
||||
formData.append("action", "authSourcesDelete");
|
||||
formData.append("auth_uid", row.AUTH_SOURCE_UID);
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSources_Ajax", formData)
|
||||
//axios.post(this.$root.baseUrl() + "authSources/authSources_Ajax", formData)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy", formData)
|
||||
.then(response => {
|
||||
response;
|
||||
this.refresh();
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<b-container fluid>
|
||||
<b-row>
|
||||
<b-col>
|
||||
<b-form-group :label="$root.translation('ID_AVAILABLE_AUTHENTICATION_SOURCES')" description="">
|
||||
<b-form-select v-model="form.availableAuthenticationSource"
|
||||
<b-form-group v-show=false :label="$root.translation('ID_AVAILABLE_AUTHENTICATION_SOURCES')" description="">
|
||||
<b-form-select v-show=false v-model="form.availableAuthenticationSource"
|
||||
:options="availableAuthenticationSources"/>
|
||||
</b-form-group>
|
||||
<b-form-group :label="$root.translation('ID_NAME')">
|
||||
@@ -380,12 +380,14 @@
|
||||
test(form) {
|
||||
let formDataForName = new FormData();
|
||||
formDataForName.append("AUTH_SOURCE_NAME", form.name);
|
||||
axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapVerifyName", formDataForName)
|
||||
//axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapVerifyName", formDataForName)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy.php?action=authSourcesVerifyName", formDataForName)
|
||||
.then(response => {
|
||||
//the name is valid
|
||||
if (response.data.row === false || (this.form.uid !== "" && typeof this.form.uid === "string")) {
|
||||
let formData = this.formToFormData(form);
|
||||
axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapTestConnection", formData)
|
||||
//axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapTestConnection", formData)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy?action=authSourcesTestConnection", formData)
|
||||
.then(response => {
|
||||
//test is successful
|
||||
if (response.data.status === "OK") {
|
||||
|
||||
@@ -141,7 +141,8 @@
|
||||
//validation name
|
||||
let formData = new FormData();
|
||||
formData.append("AUTH_SOURCE_NAME", this.fileContent.AUTH_SOURCE_NAME);
|
||||
axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapVerifyName", formData)
|
||||
//axios.post(this.$root.baseUrl() + "authSources/ldapAdvancedProxy.php?functionAccion=ldapVerifyName", formData)
|
||||
axios.post(this.$root.baseUrl() + "authSources/authSourcesProxy.php?action=authSourcesVerifyName", formData)
|
||||
.then(response => {
|
||||
this.newName = response.data.row === false;
|
||||
this.validationResult = response.data;
|
||||
|
||||
Reference in New Issue
Block a user