From 68c7e68b3f90fd980661774fdb2bb2d6140a34d0 Mon Sep 17 00:00:00 2001 From: winter Date: Mon, 16 Dec 2024 20:27:01 +0000 Subject: implement the other side of auth (hopefully?) also mostly untested for the same reason as last time --- Digitigrade/Job/ExpireInboundAuthToken.php | 34 ++++++++++++++++++++++++++++ Digitigrade/Job/RefreshOutboundAuthToken.php | 1 - Digitigrade/Job/RequestOutboundAuthToken.php | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 Digitigrade/Job/ExpireInboundAuthToken.php (limited to 'Digitigrade/Job') 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 @@ +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 diff --git a/Digitigrade/Job/RefreshOutboundAuthToken.php b/Digitigrade/Job/RefreshOutboundAuthToken.php index 588617f..72dd466 100644 --- a/Digitigrade/Job/RefreshOutboundAuthToken.php +++ b/Digitigrade/Job/RefreshOutboundAuthToken.php @@ -8,7 +8,6 @@ use Digitigrade\Model\Instance; class RefreshOutboundAuthToken extends Job { public string $domain; - public string $token; public \DateTimeInterface $when; public function __construct(string $domain, \DateTimeInterface $when) { diff --git a/Digitigrade/Job/RequestOutboundAuthToken.php b/Digitigrade/Job/RequestOutboundAuthToken.php index 69430c8..1786e32 100644 --- a/Digitigrade/Job/RequestOutboundAuthToken.php +++ b/Digitigrade/Job/RequestOutboundAuthToken.php @@ -17,7 +17,7 @@ class RequestOutboundAuthToken extends Job { } public function run() { - Logger::getInstance()->info("responding to $this->domain's dialback challenge"); + Logger::getInstance()->info("requesting token from $this->domain in response to their dialback challenge"); $instance = Instance::findByDomain($this->domain); $instance->requestOutboundAuthToken($this->secret); } -- cgit v1.3