diff options
Diffstat (limited to 'routes/integration/auth-request.php')
| -rw-r--r-- | routes/integration/auth-request.php | 10 |
1 files changed, 6 insertions, 4 deletions
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); } |
