From 6ed206ccc8843be7525245f703ea3ace80cb2a70 Mon Sep 17 00:00:00 2001 From: cogentapps <127109874+cogentapps@users.noreply.github.com> Date: Tue, 4 Jul 2023 19:25:27 +0000 Subject: [PATCH] fix auth bug --- server/src/endpoints/session.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/endpoints/session.ts b/server/src/endpoints/session.ts index 97acb0e..a6bf445 100644 --- a/server/src/endpoints/session.ts +++ b/server/src/endpoints/session.ts @@ -6,12 +6,14 @@ export default class SessionRequestHandler extends RequestHandler { async handler(req: express.Request, res: express.Response) { const request = req as any; + const authenticated = !!(request.oidc?.user?.sub || request.session?.passport?.user?.id); + const availableServiceNames = Object.keys(config.services || {}) .filter(key => { const serviceConfig = (config.services as any)?.[key]; const apiKey = serviceConfig?.apiKey; const loginRequired = serviceConfig?.loginRequired ?? true; - return apiKey && (!loginRequired || request.isAuthenticated()); + return apiKey && (!loginRequired || authenticated); }); if (request.oidc) {