Skip to content

Commit

Permalink
fix auth bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cogentapps committed Jul 4, 2023
1 parent 2d95041 commit 6ed206c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/src/endpoints/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6ed206c

Please sign in to comment.