aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Job/ExpireInboundAuthToken.php
diff options
context:
space:
mode:
authorwinter2024-12-16 20:27:01 +0000
committerwinter2024-12-16 20:41:33 +0000
commit68c7e68b3f90fd980661774fdb2bb2d6140a34d0 (patch)
tree7993de39c7c637369bdbfb22e265319b43fcbf33 /Digitigrade/Job/ExpireInboundAuthToken.php
parent2f4c1de3509141880df019ef1a6cc65981b3f6ea (diff)
implement the other side of auth (hopefully?)
also mostly untested for the same reason as last time
Diffstat (limited to 'Digitigrade/Job/ExpireInboundAuthToken.php')
-rw-r--r--Digitigrade/Job/ExpireInboundAuthToken.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/Digitigrade/Job/ExpireInboundAuthToken.php b/Digitigrade/Job/ExpireInboundAuthToken.php
new file mode 100644
index 0000000..dfb5ae6
--- /dev/null
+++ b/Digitigrade/Job/ExpireInboundAuthToken.php
@@ -0,0 +1,34 @@
+<?php
+namespace Digitigrade\Job;
+
+use Digitigrade\Job;
+use Digitigrade\JobQueue;
+use Digitigrade\Logger;
+use Digitigrade\Model\Instance;
+
+class ExpireInboundAuthToken extends Job {
+ public string $domain;
+ public string $token;
+ public \DateTimeInterface $when;
+
+ public function __construct(string $domain, string $token, \DateTimeInterface $when) {
+ $this->domain = $domain;
+ $this->token = $token;
+ $this->when = $when;
+ $this->remainingTries = 5;
+ }
+
+ public function run() {
+ Logger::getInstance()->info("expiring token for $this->domain");
+ $instance = Instance::findByDomain($this->domain);
+ if ($instance->auth->inboundToken != $this->token) {
+ Logger::getInstance()->info("actually not expiring the token because it's been refreshed");
+ return;
+ }
+ $instance->auth->inboundToken = null;
+ }
+
+ public function submit() {
+ JobQueue::getInstance()->submitDelayedUntil($this, $this->when);
+ }
+} \ No newline at end of file