added encryption to the first functions
This commit is contained in:
parent
19576dd6b7
commit
402934f02c
|
@ -63,6 +63,8 @@ class RequestController
|
||||||
* @param DomainRepository $domainRepository
|
* @param DomainRepository $domainRepository
|
||||||
* @param DynDNSRepository $dynDNSRepository
|
* @param DynDNSRepository $dynDNSRepository
|
||||||
* @param PanelRepository $panelRepository
|
* @param PanelRepository $panelRepository
|
||||||
|
* @param ConfigController $configController
|
||||||
|
* @param EncryptionController $encryptionController
|
||||||
* @param Logger $logger
|
* @param Logger $logger
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -72,6 +74,8 @@ class RequestController
|
||||||
private readonly DomainRepository $domainRepository,
|
private readonly DomainRepository $domainRepository,
|
||||||
private readonly DynDNSRepository $dynDNSRepository,
|
private readonly DynDNSRepository $dynDNSRepository,
|
||||||
private readonly PanelRepository $panelRepository,
|
private readonly PanelRepository $panelRepository,
|
||||||
|
private readonly ConfigController $configController,
|
||||||
|
private readonly EncryptionController $encryptionController,
|
||||||
private readonly Logger $logger)
|
private readonly Logger $logger)
|
||||||
{
|
{
|
||||||
$this->status = '';
|
$this->status = '';
|
||||||
|
@ -296,8 +300,11 @@ class RequestController
|
||||||
} else {
|
} else {
|
||||||
[$prefix,] = explode(separator: '.', string: $apiKey);
|
[$prefix,] = explode(separator: '.', string: $apiKey);
|
||||||
if ($apiResult = $this->apikeyRepository->findByPrefix(prefix: $prefix)) {
|
if ($apiResult = $this->apikeyRepository->findByPrefix(prefix: $prefix)) {
|
||||||
$storedHash = $apiResult->getApiToken();
|
$encryptedHash = $apiResult->getApikey();
|
||||||
if (!password_verify(password: $apiKey, hash: $storedHash)) {
|
$encryptionKey = $this->configController->getConfig(configKey: 'encryptionKey');
|
||||||
|
$decryptedHash = $this->encryptionController->safeDecrypt(encrypted: $encryptedHash, key: $encryptionKey);
|
||||||
|
|
||||||
|
if (!password_verify(password: $apiKey, hash: $decryptedHash)) {
|
||||||
$this->status = "401 Unauthorized";
|
$this->status = "401 Unauthorized";
|
||||||
$this->message = "API key mismatch.";
|
$this->message = "API key mismatch.";
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue