simplify auth check
parent
6ed206ccc8
commit
8e36104637
|
@ -6,14 +6,12 @@ export default class SessionRequestHandler extends RequestHandler {
|
||||||
async handler(req: express.Request, res: express.Response) {
|
async handler(req: express.Request, res: express.Response) {
|
||||||
const request = req as any;
|
const request = req as any;
|
||||||
|
|
||||||
const authenticated = !!(request.oidc?.user?.sub || request.session?.passport?.user?.id);
|
|
||||||
|
|
||||||
const availableServiceNames = Object.keys(config.services || {})
|
const availableServiceNames = Object.keys(config.services || {})
|
||||||
.filter(key => {
|
.filter(key => {
|
||||||
const serviceConfig = (config.services as any)?.[key];
|
const serviceConfig = (config.services as any)?.[key];
|
||||||
const apiKey = serviceConfig?.apiKey;
|
const apiKey = serviceConfig?.apiKey;
|
||||||
const loginRequired = serviceConfig?.loginRequired ?? true;
|
const loginRequired = serviceConfig?.loginRequired ?? true;
|
||||||
return apiKey && (!loginRequired || authenticated);
|
return apiKey && (!loginRequired || this.userID);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (request.oidc) {
|
if (request.oidc) {
|
||||||
|
|
Loading…
Reference in New Issue