-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauth.php
More file actions
59 lines (47 loc) · 2.01 KB
/
auth.php
File metadata and controls
59 lines (47 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
//
// Auth API
// Writen by Zane Reick
//
error_reporting(0);
//Make sure to set these variables to the correct locations!!
//User set variables:
$secConfLoc = "./security_conf.ini.php"; //Security Configuration Location
$rjwtConf = "./rjwt.ini.php"; //RJWT Configuration Location
#header('Content-Type: application/json');
require_once 'rjwt_mod.php';
// Retreive recved values
$username = protect($_POST["username"]);
$password = protect($_POST["password"]);
$passkey = protect($_POST["passkey"]);
$endClient = protect($_POST["endClient"]);
// Import security config
$fChk = fopen($secConfLoc, "r") or die("Invalid configuration location!\n");
fclose($fChk);
$securityConf = parse_ini_file($secConfLoc);
#print($securityConf['passkey']."<br />");
#print(return_var_dump($securityConf['allowed_users']));
#print($securityConf['allowed_users'][1]);
#print($username);
#print($password);
#print($passkey);
#print($endClient);
if (in_array($endClient, $securityConf['allowed_users']) || (!$username || !$password)) {
if ($passkey == $securityConf['passkey']) {
$authenticated = rjwtAuth($username, $password, "./rjwt.ini.php");
if ($authenticated === false) {
header('Content-Type: application/json');
echo json_encode([ "validHost" => "True", "validKey" => "True", "error" => "Invalid Username or Password", "authenticated" => "False"]);
} else {
// access request was accepted - client authenticated successfully
header('Content-Type: application/json');
echo json_encode([ "validHost" => "True", "validKey" => "True", "error" => "null", "authenticated" => "True"]);
}
} else {
header('Content-Type: application/json');
echo json_encode([ "validHost" => "True", "validKey" => "False", "error" => "null", "authenticated" => "False"]);
}
} else {
header('Content-Type: application/json');
echo json_encode([ "validHost" => "False", "validKey" => "False", "error" => "null", "authenticated" => "False"]);
}