aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/auth.php
diff options
context:
space:
mode:
authorwinter2024-12-17 18:39:18 +0000
committerwinter2024-12-17 18:39:18 +0000
commit085762ec174eae1c519ec14db632f5ba197ed3c7 (patch)
tree9ad49bc839b5f72ded47c119ff01a09dfa0b934a /routes/auth.php
parentbc2cd99b108b8755a648c3915714e7c0e0771548 (diff)
hopefully implement push!
again i can't really test this yet because i don't have two https instances that can talk to each other. soon i will set that up and test all these recent commits
Diffstat (limited to 'routes/auth.php')
-rw-r--r--routes/auth.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/routes/auth.php b/routes/auth.php
index 2127a46..d64331e 100644
--- a/routes/auth.php
+++ b/routes/auth.php
@@ -2,7 +2,7 @@
use Digitigrade\GlobalConfig;
use Digitigrade\HttpResponseStatus\BadRequest;
-use Digitigrade\HttpResponseStatus\Forbidden;
+use Digitigrade\HttpResponseStatus\Unauthorized;
use Digitigrade\Job\ExpireInboundAuthToken;
use Digitigrade\Job\RequestOutboundAuthToken;
use Digitigrade\Model\Instance;
@@ -19,8 +19,8 @@ Router::getInstance()->mount('/auth/main', function (array $args) {
if (!isset($_GET['target'])) {
throw new BadRequest('you need to specify the `target` GET parameter');
}
- $domain = explode('/', $_GET['target'])[2];
- $instance = Instance::findByDomain($domain);
+ $domain = hostname_from_uri($_GET['target']);
+ $instance = Instance::findByHostname($domain);
if ($instance == null) {
throw new RuntimeException("i can't find your instance information, sorry");
}
@@ -51,7 +51,7 @@ Router::getInstance()->mount('/auth/main', function (array $args) {
}
$instance = Instance::findByDialbackSecret($_GET['secret']);
if ($instance == null) {
- throw new Forbidden('the provided secret is invalid!');
+ throw new Unauthorized('the provided secret is invalid!');
}
$instance->auth->secret = null; // it's been used now
@@ -79,7 +79,7 @@ Router::getInstance()->mount('/auth/main', function (array $args) {
}
$instance = Instance::findByInboundAuthToken($_GET['token']);
if ($instance == null) {
- throw new Forbidden('the provided token is invalid!');
+ throw new Unauthorized('the provided token is invalid!');
}
$instance->auth->inboundToken = random_printable_bytes();
@@ -109,7 +109,7 @@ Router::getInstance()->mount('/auth/dialback', function (array $args) {
if (!isset($_POST['origin'], $_POST['secret'])) {
throw new BadRequest('send the `origin` and `secret` parameters as POST data please :3');
}
- $instance = Instance::findByDomain($_POST['origin']);
+ $instance = Instance::findByHostname($_POST['origin']);
if ($instance == null) {
throw new BadRequest("i can't seem to find your instance information!");
}