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); $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); }