Skip to content

Commit

Permalink
composer run cs:fix
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>
  • Loading branch information
docjyJ committed Oct 2, 2024
1 parent 3f9cd0a commit 38a5aa8
Show file tree
Hide file tree
Showing 43 changed files with 11,188 additions and 11,252 deletions.
26 changes: 13 additions & 13 deletions php/domain-validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

$domain = $_GET['domain'] ?? '';

if (!str_contains($domain, '.')) {
http_response_code(400);
} elseif (str_contains($domain, '/')) {
http_response_code(400);
} elseif (str_contains($domain, ':')) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_IP)) {
http_response_code(400);
if (!str_contains($domain, '.')) {
http_response_code(400);
} elseif (str_contains($domain, '/')) {
http_response_code(400);
} elseif (str_contains($domain, ':')) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_IP)) {
http_response_code(400);
} else {
// Commented because logging is disabled as otherwise all attempts will be logged which spams the logs
// error_log($domain . ' was accepted as valid domain.');
http_response_code(200);
// Commented because logging is disabled as otherwise all attempts will be logged which spams the logs
// error_log($domain . ' was accepted as valid domain.');
http_response_code(200);
}
56 changes: 28 additions & 28 deletions php/src/Auth/AuthManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@

use AIO\Data\ConfigurationManager;
use AIO\Data\DataConst;
use \DateTime;
use DateTime;

class AuthManager {
private const string SESSION_KEY = 'aio_authenticated';
private ConfigurationManager $configurationManager;
private const string SESSION_KEY = 'aio_authenticated';
private ConfigurationManager $configurationManager;

public function __construct(ConfigurationManager $configurationManager) {
$this->configurationManager = $configurationManager;
}
public function __construct(ConfigurationManager $configurationManager) {
$this->configurationManager = $configurationManager;
}

public function CheckCredentials(string $password) : bool {
return hash_equals($this->configurationManager->GetPassword(), $password);
}
public function CheckCredentials(string $password) : bool {
return hash_equals($this->configurationManager->GetPassword(), $password);
}

public function CheckToken(string $token) : bool {
return hash_equals($this->configurationManager->GetToken(), $token);
}
public function CheckToken(string $token) : bool {
return hash_equals($this->configurationManager->GetToken(), $token);
}

public function SetAuthState(bool $isLoggedIn) : void {
public function SetAuthState(bool $isLoggedIn) : void {

if (!$this->IsAuthenticated() && $isLoggedIn === true) {
$date = new DateTime();
$dateTime = $date->getTimestamp();
$_SESSION['date_time'] = $dateTime;
if (!$this->IsAuthenticated() && $isLoggedIn === true) {
$date = new DateTime();
$dateTime = $date->getTimestamp();
$_SESSION['date_time'] = $dateTime;

$df = disk_free_space(DataConst::GetSessionDirectory());
if ($df !== false && (int)$df < 10240) {
error_log(DataConst::GetSessionDirectory() . " has only less than 10KB free space. The login might not succeed because of that!");
}
$df = disk_free_space(DataConst::GetSessionDirectory());
if ($df !== false && (int)$df < 10240) {
error_log(DataConst::GetSessionDirectory() . ' has only less than 10KB free space. The login might not succeed because of that!');
}

file_put_contents(DataConst::GetSessionDateFile(), (string)$dateTime);
}
file_put_contents(DataConst::GetSessionDateFile(), (string)$dateTime);
}

$_SESSION[self::SESSION_KEY] = $isLoggedIn;
}
$_SESSION[self::SESSION_KEY] = $isLoggedIn;
}

public function IsAuthenticated() : bool {
return isset($_SESSION[self::SESSION_KEY]) && $_SESSION[self::SESSION_KEY] === true;
}
public function IsAuthenticated() : bool {
return isset($_SESSION[self::SESSION_KEY]) && $_SESSION[self::SESSION_KEY] === true;
}
}
Loading

0 comments on commit 38a5aa8

Please sign in to comment.