Skip to content

Commit c2db2be

Browse files
committed
fix: allow access to /keyauth paths without OAuth2
1 parent c433702 commit c2db2be

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/handlers/middleware.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ import express from 'express';
22
import { Request, Response, NextFunction } from "express";
33
import { CustomSessionData } from "./session";
44
import { IntraUser } from '../intra/oauth';
5-
import { hasPiscineHistoryAccess } from '../utils';
5+
import { checkDirectAuthSecret, hasPiscineHistoryAccess } from '../utils';
66

77

88
const checkIfAuthenticated = function(req: Request, res: Response, next: NextFunction) {
9+
if (req.path.endsWith('/keyauth') && checkDirectAuthSecret(req)) {
10+
// Authorization Bearer header is valid, do not require authentication using OAuth2
11+
return next();
12+
}
913
if (req.path.startsWith('/login') || req.path.startsWith('/logout') || res.statusCode === 503) {
1014
return next();
1115
}

0 commit comments

Comments
 (0)