diff options
| author | winter Sparkles | 2026-08-09 15:44:18 +0100 |
|---|---|---|
| committer | winter Sparkles | 2026-08-09 15:44:18 +0100 |
| commit | 96387025da63025894f6259f7eebed0fc6fc53ac (patch) | |
| tree | a83d73eeb7ec419b24ff78291634503d4ebceec1 /misc.php | |
| parent | c8998ccdff070d7c73a634e031a041260b87c3b1 (diff) | |
implement the rest of login process incl. cookie redirects and 'next'
Diffstat (limited to 'misc.php')
| -rw-r--r-- | misc.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/misc.php b/misc.php new file mode 100644 index 0000000..7965066 --- /dev/null +++ b/misc.php @@ -0,0 +1,27 @@ +<?php +namespace Psso; + +function isValidRedirect(string $target, array $config): bool { + $redirHost = parse_url($target, PHP_URL_HOST); + + $primary = explode('.', $config['site']['primary-domain'], 2)[1]; + if (str_ends_with($redirHost, '.' . $primary) || $redirHost == $primary) { + return true; + } + + foreach ($config['site']['cookie-domains'] ?? [] as $cdomain) { + $upper = explode('.', $cdomain, 2)[1]; + if (str_ends_with($redirHost, '.' . $upper) || $redirHost == $upper) { + return true; + } + } + + foreach ($config['site']['redirect-domains'] ?? [] as $rdomain) { + if (str_ends_with($redirHost, '.' . $rdomain) || + $redirHost == $rdomain) { + return true; + } + } + + return false; +} |
