Moved fetchUserInfo call to authorization.js middleware. Catch fetchUserInfo exceptions, causing invalided session to be stuck

This commit is contained in:
Glenn de Haan
2025-11-11 18:57:04 +01:00
parent 10f95864f9
commit 7bffaa4ebb
4 changed files with 12 additions and 3 deletions

View File

@@ -51,6 +51,15 @@ module.exports = {
// Check if OIDC is enabled then verify user status
if(variables.authOidcEnabled) {
oidc = req.oidc.isAuthenticated();
// Retrieve user info/verify user session is still valid
req.user = await req.oidc.fetchUserInfo().catch(() => {
res.redirect(302, `${req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : ''}/login`);
});
if(!req.user) {
return;
}
}
// Check if user is authorized by a service