diff options
| author | winter | 2024-12-14 21:24:48 +0000 |
|---|---|---|
| committer | winter | 2024-12-14 21:45:59 +0000 |
| commit | 2f4c1de3509141880df019ef1a6cc65981b3f6ea (patch) | |
| tree | 0021f3a860d6c80869d4af5d366393f1d0eea288 /routes | |
| parent | 0c6497ff02b8118bcefee37cc6fe0cbc02df4bb4 (diff) | |
implement outbound auth? untested
untested because i don't have another instance to test it against ....
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/auth.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/routes/auth.php b/routes/auth.php new file mode 100644 index 0000000..b44d76a --- /dev/null +++ b/routes/auth.php @@ -0,0 +1,22 @@ +<?php + +use Digitigrade\HttpResponseStatus\BadRequest; +use Digitigrade\Job\RequestOutboundAuthToken; +use Digitigrade\Model\Instance; +use Digitigrade\Router; + +Router::getInstance()->mount('/auth/dialback', function (array $args) { + // just respond to the dialback challenge! + 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']); + if ($instance == null) { + throw new BadRequest("i can't seem to find your instance information!"); + } + if (!isset($instance->endpoints->auth)) { + throw new BadRequest("you don't seem to have an auth endpoint"); + } + + (new RequestOutboundAuthToken($instance->domain, $_POST['secret']))->submit(); +});
\ No newline at end of file |
