From 3262ff379149bdcb1546cecf04581384a7e05691 Mon Sep 17 00:00:00 2001 From: Matthew Baggett Date: Thu, 25 Jan 2024 16:02:53 +0100 Subject: [PATCH] fix misdetection of every file being changed every time --- bouncer/src/Bouncer.php | 5 +++-- bouncer/src/Target.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bouncer/src/Bouncer.php b/bouncer/src/Bouncer.php index 4bc28f8..6f3e8c0 100644 --- a/bouncer/src/Bouncer.php +++ b/bouncer/src/Bouncer.php @@ -716,8 +716,9 @@ class Bouncer } if ($target->hasAuth()) { - $authFileHash = $this->configFilesystem->fileExists($target->getAuthFileName()) ? sha1($this->configFilesystem->read($target->getAuthFileName())) : null; - if (sha1($target->getAuthFileData()) != $authFileHash) { + $authFileHash = $this->configFilesystem->fileExists($target->getAuthFileName()) ? $this->configFilesystem->read($target->getAuthFileName()) : null; + if ($target->getAuthHash() != $authFileHash) { + $this->configFilesystem->write($target->getAuthFileName() . '.hash', $target->getAuthHash()); $this->configFilesystem->write($target->getAuthFileName(), $target->getAuthFileData()); $changed = true; } diff --git a/bouncer/src/Target.php b/bouncer/src/Target.php index 074addb..514f6e1 100644 --- a/bouncer/src/Target.php +++ b/bouncer/src/Target.php @@ -98,6 +98,19 @@ class Target return $this; } + public function getAuth(): array + { + return [ + 'username' => $this->getUsername(), + 'password' => $this->getPassword(), + ]; + } + + public function getAuthHash(): string + { + return sha1(implode(':', $this->getAuth())); + } + public function setAuth(string $username, string $password): self { return $this->setUsername($username)->setPassword($password);