aboutsummaryrefslogtreecommitdiff
path: root/routes/continue.php
diff options
context:
space:
mode:
authorwinter Sparkles2026-08-09 15:44:18 +0100
committerwinter Sparkles2026-08-09 15:44:18 +0100
commit96387025da63025894f6259f7eebed0fc6fc53ac (patch)
treea83d73eeb7ec419b24ff78291634503d4ebceec1 /routes/continue.php
parentc8998ccdff070d7c73a634e031a041260b87c3b1 (diff)
implement the rest of login process incl. cookie redirects and 'next'
Diffstat (limited to 'routes/continue.php')
-rw-r--r--routes/continue.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/routes/continue.php b/routes/continue.php
new file mode 100644
index 0000000..2839ef9
--- /dev/null
+++ b/routes/continue.php
@@ -0,0 +1,33 @@
+<?php
+
+// this is the confusingly named cookie-relay page
+
+function GET(array $config) {
+ $ci = array_search($_SERVER['HTTP_HOST'],
+ $config['site']['cookie-domains'] ?? []);
+ if ($ci === false) {
+ header('Location: https://' . $config['site']['primary-domain']);
+ return;
+ }
+ if (!isset($_GET['sid'])) {
+ header('Location: /');
+ return;
+ }
+
+ Psso\Session::override($_GET['sid']);
+
+ $nextDomain = $config['site']['cookie-domains'][$ci + 1] ?? null;
+ if (!isset($nextDomain)) {
+ $redir = $_GET['next'] ?? null;
+ if (isset($redir) && Psso\isValidRedirect($redir, $config)) {
+ header('Location: ' . $redir);
+ } else {
+ header('Location: https://' . $config['site']['primary-domain']);
+ }
+ return;
+ }
+ $target = 'Location: https://' . $nextDomain . '/continue'
+ . '?sid=' . urlencode($_GET['sid']);
+ if (isset($_GET['next'])) $target .= '&next=' . urlencode($_GET['next']);
+ header('Location: ' . $target);
+}