aboutsummaryrefslogtreecommitdiff
path: root/routes/continue.php
diff options
context:
space:
mode:
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);
+}