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 /routes/integration/auth-request.php | |
| parent | c8998ccdff070d7c73a634e031a041260b87c3b1 (diff) | |
implement the rest of login process incl. cookie redirects and 'next'
Diffstat (limited to 'routes/integration/auth-request.php')
| -rw-r--r-- | routes/integration/auth-request.php | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/routes/integration/auth-request.php b/routes/integration/auth-request.php index 82d1f03..51b54d8 100644 --- a/routes/integration/auth-request.php +++ b/routes/integration/auth-request.php @@ -4,11 +4,27 @@ // returns 200 for allowed requests // otherwise, returns 401 and sends the login page url as a header +function addHeader(array $config, string $baseName, string $value): void { + $prefix = $config['integration']['header-prefix']; + header("$prefix-$baseName: $value"); +} + function GET(array $config) { - // in the absence of any auth backends i will say No to all requests + $session = Psso\Session::get(); + $identity = $session->getIdentity(); + if (isset($identity)) { + // ok + addHeader($config, 'User', $identity->user); + addHeader($config, 'Groups', implode(',', $identity->groups)); + foreach ($identity->extras as $key => $value) { + if ($value !== null) addHeader($config, ucfirst($key), $value); + } + return; + } + http_response_code(401); - header( - $config['integration']['header-prefix'] . '-Location: https://' - . $config['site']['primary-domain'] . '/login' + addHeader( + $config, 'Location', + 'https://' . $config['site']['primary-domain'] . '/login' ); } |
