diff options
| -rw-r--r-- | Psso/Router.php | 2 | ||||
| -rw-r--r-- | routes/integration/auth-request.php | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/Psso/Router.php b/Psso/Router.php index ba0dd53..6ad63cd 100644 --- a/Psso/Router.php +++ b/Psso/Router.php @@ -41,7 +41,7 @@ class Router { function dispatch(string $path) { // actually check the hostname lol if ($_SERVER['HTTP_HOST'] != $this->config['site']['primary-domain'] && - $path != '/continue') { + $path != '/continue' && !str_starts_with($path, '/integration/')) { header('Location: https://' . $this->config['site']['primary-domain']); return; diff --git a/routes/integration/auth-request.php b/routes/integration/auth-request.php index 51b54d8..21c5d11 100644 --- a/routes/integration/auth-request.php +++ b/routes/integration/auth-request.php @@ -3,6 +3,7 @@ // nginx (and others?) auth_request style endpoint // returns 200 for allowed requests // otherwise, returns 401 and sends the login page url as a header +// if request header X-Original-Uri is given, it puts it as the post-login redir function addHeader(array $config, string $baseName, string $value): void { $prefix = $config['integration']['header-prefix']; @@ -23,8 +24,9 @@ function GET(array $config) { } http_response_code(401); - addHeader( - $config, 'Location', - 'https://' . $config['site']['primary-domain'] . '/login' - ); + $login = 'https://' . $config['site']['primary-domain'] . '/login'; + if (isset($_SERVER['HTTP_X_ORIGINAL_URI'])) { + $login .= '?next=' . urlencode($_SERVER['HTTP_X_ORIGINAL_URI']); + } + addHeader($config, 'Location', $login); } |
