Fonctionnalité #14635
Authentification LemonLDAP des utilisateurs
Description
Client : TCO
LemonLDAP fournit dans l’entête HTTP lors de la connexion à MaarchCourrier un header REMOTE_USER avec pour valeur le nom d’utilisateur.
Une légère adaptation du code a été nécessaire pour faire fonctionner cette connexion.
Les modifications effectuées :
fichier custom/cs_maarch/apps/maarch_entreprise/xml/login_method.xml : ajout de la section suivante, pour toutes autres méthodes, ENABLED est à false.
<METHOD>
<ID>lemonldap</ID>
<NAME>LemonLDAP</NAME>
<SCRIPT>lemonLDAPConnect.php</SCRIPT>
<ENABLED>true</ENABLED>
</METHOD>
nouveau fichier custom/cs_maarch/apps/maarch_entreprise/lemonLDAPConnect.php :
<?php
$login = getallheaders()['REMOTE_USER'];
if (!empty($login)) {
$password = 'aFakePass';
require_once('core/class/class_core_tools.php');
require_once 'core/class/class_security.php';
require_once 'core/class/class_db_pdo.php';
$core = new core_tools();
$sec = new security();
$database = new Database();
$stmt = $database->query("SELECT 1 FROM users WHERE user_id ILIKE ?", array($login));
$result = $stmt->fetch();
if ($result) {
$_SESSION['error'] = '';
$res = $sec->login($login, $password, 'shibboleth');
$_SESSION['user'] = $res['user'];
if (empty($_SESSION['error'])) {
$_SESSION['error'] = $res['error'];
}
if ($res['error'] == '') {
\SrcCore\models\AuthenticationModel::setCookieAuth(['userId' => $login]);
//login OK
$trace = new history();
header('location: ' . $_SESSION['config']['businessappurl']. $res['url']);
exit();
} else {
$_SESSION['error'] = $res['error'];
echo $_SESSION['error'];
exit;
}
} else {
$_SESSION['error'] = _USER_NOT_EXIST . ' ' . $login;
echo $_SESSION['error'];
exit;
}
}
Ce fichier est une copie légèrement modifiée de shibbolethConnect.php, simplement en mettant $login = getallheaders()['REMOTE_USER']; au lieu de $login = $_SERVER['REMOTE_USER']; et en supprimant la vérification $_SERVER['AUTH_TYPE'] = 'shibboleth'
D’ailleurs ici pourquoi n’avoir pas mis $_SERVER['AUTH_TYPE'] == 'shibboleth' avec double égal ? C’est le cas dans le fichier shibbolethConnect.php sur la forge, est-ce une faute de frappe ?
Est-il possible d’intégrer ce code à Maarch Courrier ?
History
#2 Updated by Support Maarch over 1 year ago
- Status changed from A qualifier to A traiter
#3 Updated by Emmanuel DILLARD over 1 year ago
- Status changed from A traiter to Etude planifiée
#4 Updated by Emmanuel DILLARD over 1 year ago
- Status changed from Etude planifiée to En attente financement
- Assignee changed from EDI PO to Quentin RIBAC
- Target version changed from 20.03.XX to 20.10 (Support actif)
#6 Updated by Emmanuel DILLARD over 1 year ago
- Priority changed from 0-Bloquant to 2-Sérieux
#7 Updated by Emmanuel DILLARD over 1 year ago
- Target version changed from 20.10 (Support actif) to Inscription Backlog Courrier
#8 Updated by Emmanuel DILLARD over 1 year ago
- Status changed from En attente financement to A étudier
#9 Updated by Emmanuel DILLARD about 1 year ago
- Status changed from A étudier to En attente financement
#10 Updated by Quentin RIBAC about 1 year ago
- Assignee deleted (
Quentin RIBAC)
#11 Updated by Emmanuel DILLARD 11 months ago
- Project changed from Backlog to Backlog Courrier
- Target version changed from Inscription Backlog Courrier to Inscription Backlog
#13 Updated by Emmanuel DILLARD 11 months ago
- Assignee set to EDI PO
#14 Updated by Emmanuel DILLARD 10 months ago
- Assignee changed from EDI PO to Emmanuel DILLARD
#15 Updated by Emmanuel DILLARD 10 months ago
- Assignee deleted (
Emmanuel DILLARD)
#16 Updated by Emmanuel DILLARD 5 months ago
- Assignee set to Ines MKACHER
#17 Updated by Ines MKACHER 3 months ago
- Target version changed from Inscription Backlog to Develop