Line breaks and diagnostic logs

This commit is contained in:
Angus B. Grieve-Smith 2020-04-27 17:00:45 -04:00
parent b44b6c4116
commit 0e06bf6c97
3 changed files with 18 additions and 4 deletions

View File

@ -225,7 +225,7 @@ class LDAP implements LDAPInterface
throw new Exception('An error has occured during ldap_first_entry execution. Please check parameter of LDAP/getData.');
}
error_log("LDAP \$data = " . json_encode($data));
error_log("LDAP \$data = " . var_dump($data));
$mail = ldap_get_values($this->ldap_server, $data, "mail");
if (!$mail)
@ -239,7 +239,9 @@ class LDAP implements LDAPInterface
throw new Exception('An error has occured during ldap_get_values execution (complete name). Please check parameter of LDAP/getData.');
}
return array("mail" => $mail[0], "cn" => $cn[0]);
$return_data = array("mail" => $mail[0], "cn" => $cn[0]);
error_log("LDAP \$return_data = " . json_encode($return_data));
return $return_data;
}
/*

View File

@ -34,8 +34,17 @@ try
{
$data = $ldap->getDataForMattermost($ldap_base_dn,$ldap_filter,$ldap_bind_dn,$ldap_bind_pass,$ldap_search_attribute,$user);
// Here is the patch for Mattermost 4.4 and older. Gitlab has changed the JSON output of oauth service. Many data are not used by Mattermost, but there is a stack error if we delete them. That's the reason why date and many parameters are null or empty.
error_log("resource.php \$data = " . json_encode($data);
/* Here is the patch for Mattermost 4.4 and older. Gitlab has changed
the JSON output of oauth service. Many data are not used by
Mattermost, but there is a stack error if we delete them. That's the
reason why date and many parameters are null or empty.
*/
if ($data) {
error_log("resource.php \$data = " . json_encode($data));
} else {
error_log("$data is null");
}
$resp = array(
"id" => $assoc_id,
"name" => $data['cn'],
@ -70,6 +79,7 @@ try
"external" => false,
"shared_runners_minutes_limit" => null
);
error_log("\$resp = " . json_encode($resp));
// Below is the old version, still consistent with Mattermost before version 4.4
// $resp = array("name" => $data['cn'],"username" => $user,"id" => $assoc_id,"state" => "active","email" => $data['mail']);

View File

@ -9,6 +9,8 @@ require_once __DIR__.'/server.php';
// Handle a request for an OAuth2.0 Access Token and send the response to the client
error_log("token.php \$_POST = " . json_encode($_POST));
// The Mattermost server seems to be returning bare http urls, even though there is no http url in the config.json
if (substr($_POST["redirect_uri"],0,5) == "http:") {
$_POST["redirect_uri"] = "https" . substr($_POST["redirect_uri"],4);
}