diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2024-12-04 14:41:53 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2024-12-05 13:18:34 -0100 |
commit | a6e8d41c256093574006ce277af306bbe474da6d (patch) | |
tree | 28cdbdca8cfe8d3275b5a56f00efa09110bea465 /lib | |
parent | c9073f7ab7be631e90be77b46d51369d3dbbf5fe (diff) | |
download | nextcloud-server-a6e8d41c256093574006ce277af306bbe474da6d.tar.gz nextcloud-server-a6e8d41c256093574006ce277af306bbe474da6d.zip |
fix(signed-request): trigger metadata insert with default value manually
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Security/Signature/SignatureManager.php | 3 | ||||
-rw-r--r-- | lib/unstable/Security/Signature/Model/Signatory.php | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/private/Security/Signature/SignatureManager.php b/lib/private/Security/Signature/SignatureManager.php index fa52bbfaa7c..91a06e29b4a 100644 --- a/lib/private/Security/Signature/SignatureManager.php +++ b/lib/private/Security/Signature/SignatureManager.php @@ -142,7 +142,7 @@ class SignatureManager implements ISignatureManager { if ($ttlSignatory > 0 && $knownSignatory->getLastUpdated() < (time() - $ttlSignatory)) { $signatory = $this->getSaneRemoteSignatory($signatoryManager, $signedRequest); $this->updateSignatoryMetadata($signatory); - $knownSignatory->setMetadata($signatory->getMetadata()); + $knownSignatory->setMetadata($signatory->getMetadata() ?? []); } $signedRequest->setSignatory($knownSignatory); @@ -353,6 +353,7 @@ class SignatureManager implements ISignatureManager { $time = time(); $signatory->setCreation($time); $signatory->setLastUpdated($time); + $signatory->setMetadata($signatory->getMetadata() ?? []); // trigger insert on field metadata using current or default value $this->mapper->insert($signatory); } diff --git a/lib/unstable/Security/Signature/Model/Signatory.php b/lib/unstable/Security/Signature/Model/Signatory.php index d42be9c4544..c3a275082ae 100644 --- a/lib/unstable/Security/Signature/Model/Signatory.php +++ b/lib/unstable/Security/Signature/Model/Signatory.php @@ -42,7 +42,7 @@ use OCP\AppFramework\Db\Entity; * @method void setAccount(string $account) * @method string getAccount() * @method void setMetadata(array $metadata) - * @method array getMetadata() + * @method ?array getMetadata() * @method void setCreation(int $creation) * @method int getCreation() * @method void setLastUpdated(int $creation) @@ -59,7 +59,7 @@ class Signatory extends Entity implements JsonSerializable { protected string $account = ''; protected int $type = 9; protected int $status = 1; - protected array $metadata = []; + protected ?array $metadata = null; protected int $creation = 0; protected int $lastUpdated = 0; |