aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/auth.php
diff options
context:
space:
mode:
Diffstat (limited to 'routes/auth.php')
-rw-r--r--routes/auth.php22
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