+ Full Name
+ E-mail
+ For the user ' . $_SESSION['uid'] . '
+
+
+
+
-
-
-
Mattermost desires access to your LDAP data:
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-');
+ ');
}
// print the authorization code if the user has authorized your client
@@ -122,4 +89,4 @@ if ($is_authorized)
}
// Send message in case of error
-$response->send();
\ No newline at end of file
+$response->send();
diff --git a/oauth/connexion.php b/oauth/connexion.php
deleted file mode 100644
index 57edba1..0000000
--- a/oauth/connexion.php
+++ /dev/null
@@ -1,77 +0,0 @@
-
- */
-
-// include our LDAP object
-require_once __DIR__.'/LDAP/LDAP.php';
-require_once __DIR__.'/LDAP/config_ldap.php';
-
-
-// Verify all fields have been filled
-if (empty($_POST['user']) || empty($_POST['password']))
-{
- echo 'Please fill in your Username and Password
';
- echo 'Click here to come back to login page';
-}
-else
-{
- // Check received data length (to prevent code injection)
- if (strlen($_POST['user']) > 15)
- {
- echo 'Username has incorrect format ... Please try again
';
- echo 'Click here to come back to login page';
- }
- elseif (strlen($_POST['password']) > 50 || strlen($_POST['password']) <= 7)
- {
- echo 'Password has incorrect format ... Please try again
';
- echo 'Click here to come back to login page';
- }
- else
- {
- // Remove every html tag and useless space on username (to prevent XSS)
- $user=strip_tags(trim($_POST['user']));
-
- $user=$_POST['user'];
- $password=$_POST['password'];
-
- // Open a LDAP connection
- $ldap = new LDAP($ldap_host,$ldap_port,$ldap_version);
-
- // Check user credential on LDAP
- try{
- $authenticated = $ldap->checkLogin($user,$password,$ldap_search_attribute,$ldap_filter,$ldap_base_dn,$ldap_bind_dn,$ldap_bind_pass);
- }
- catch (Exception $e)
- {
- $resp = json_encode(array("error" => "Impossible to get data", "message" => $e->getMessage()));
- $authenticated = false;
- }
-
- // If user is authenticated
- if ($authenticated)
- {
- $_SESSION['uid']=$user;
-
- // If user came here with an autorize request, redirect him to the authorize page. Else prompt a simple message.
- if (isset($_SESSION['auth_page']))
- {
- $auth_page=$_SESSION['auth_page'];
- header('Location: ' . $auth_page);
- exit();
- }
- else
- {
- echo "Congratulation you are authenticated !
However there is nothing to do here ...";
- }
- }
- // check login on LDAP has failed. Login and password were invalid or LDAP is unreachable
- else
- {
- echo "Authentication failed ... Check your username and password. If error persist contact your administrator.
";
- echo 'Click here to come back to login page';
- echo '
+
+
diff --git a/oauth/images/auth_icon.png b/oauth/images/auth_icon.png
new file mode 100644
index 0000000..28e98fd
Binary files /dev/null and b/oauth/images/auth_icon.png differ
diff --git a/oauth/images/prompt_icon.png b/oauth/images/prompt_icon.png
new file mode 100644
index 0000000..74cb2bc
Binary files /dev/null and b/oauth/images/prompt_icon.png differ
diff --git a/oauth/index.php b/oauth/index.php
index 11190e7..adb40e2 100644
--- a/oauth/index.php
+++ b/oauth/index.php
@@ -1,72 +1,91 @@
+/**
+ * @author Denis CLAVIER
+ * A modified verion by dimst23
+ */
-
-
-
-
- LDAP Connection Interface
-
-
-
-
-
-
-
-
-
+// include our LDAP object
+require_once __DIR__.'/LDAP/LDAP.php';
+require_once __DIR__.'/LDAP/config_ldap.php';
-
-
-
LDAP Authentification
-
+$prompt_template = new DOMDocument();
+$prompt_template->loadHTMLFile('form_prompt.html');
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+function messageShow($html_template, $message = 'No Msg') {
+ $modification_node = $html_template->getElementsByTagName('div')->item(5);
+ $page_fragment = $html_template->createDocumentFragment();
+ $page_fragment->appendXML($message);
+
+ $modification_node->appendChild($page_fragment);
+
+ echo $html_template->saveHTML();
+}
+
+
+// Verify all fields have been filled
+if (empty($_POST['user']) || empty($_POST['password']))
+{
+ if (empty($_POST['user'])) {
+ messageShow($prompt_template, 'Username field can\'t be empty.');
+ } else {
+ messageShow($prompt_template, 'Password field can\'t be empty.');
+ }
+}
+else
+{
+ // Check received data length (to prevent code injection)
+ if (strlen($_POST['user']) > 15)
+ {
+ messageShow($prompt_template, 'Username has incorrect format ... Please try again');
+ }
+ elseif (strlen($_POST['password']) > 50 || strlen($_POST['password']) <= 7)
+ {
+ messageShow($prompt_template, 'Password has incorrect format ... Please try again');
+ }
+ else
+ {
+ // Remove every html tag and useless space on username (to prevent XSS)
+ $user=strip_tags(trim($_POST['user']));
+
+ $user=$_POST['user'];
+ $password=$_POST['password'];
+
+ // Open a LDAP connection
+ $ldap = new LDAP($ldap_host,$ldap_port,$ldap_version);
+
+ // Check user credential on LDAP
+ try{
+ $authenticated = $ldap->checkLogin($user,$password,$ldap_search_attribute,$ldap_filter,$ldap_base_dn,$ldap_bind_dn,$ldap_bind_pass);
+ }
+ catch (Exception $e)
+ {
+ $authenticated = false;
+ }
+
+ // If user is authenticated
+ if ($authenticated)
+ {
+ $_SESSION['uid']=$user;
+
+ // If user came here with an autorize request, redirect him to the authorize page. Else prompt a simple message.
+ if (isset($_SESSION['auth_page']))
+ {
+ $auth_page=$_SESSION['auth_page'];
+ header('Location: ' . $auth_page);
+ exit();
+ }
+ else
+ {
+ messageShow($prompt_template, 'Congratulation you are authenticated !
However there is nothing to do here ...');
+ }
+ }
+ // check login on LDAP has failed. Login and password were invalid or LDAP is unreachable
+ else
+ {
+ messageShow($prompt_template, 'Authentication failed ... Check your username and password. If the error persists contact your administrator.