Fixed where /api/clients paths are bypassed

Instead of adding `/client` in the white list, we isolate it out to check if the path starts with `APP_PREFIX/client` so then client will bypassed but not `/api/clients`
This commit is contained in:
Donald Zou
2026-03-28 23:33:47 +08:00
parent 22df8a1b1f
commit 920f832297

View File

@@ -249,12 +249,14 @@ def auth_req():
whiteList = [ whiteList = [
'/static/', 'validateAuthentication', 'authenticate', 'getDashboardConfiguration', '/static/', 'validateAuthentication', 'authenticate', 'getDashboardConfiguration',
'getDashboardTheme', 'getDashboardVersion', 'sharePeer/get', 'isTotpEnabled', 'locale', 'getDashboardTheme', 'getDashboardVersion', 'sharePeer/get', 'isTotpEnabled', 'locale',
'/client'
] ]
appPrefix = APP_PREFIX if len(APP_PREFIX) > 0 else ''
clientPrefix = f"{appPrefix}/client"
if (("username" not in session or session.get("role") != "admin") if (("username" not in session or session.get("role") != "admin")
and (f"{(APP_PREFIX if len(APP_PREFIX) > 0 else '')}/" != request.path and (f"{appPrefix}/" != request.path
and f"{(APP_PREFIX if len(APP_PREFIX) > 0 else '')}" != request.path) and f"{appPrefix}" != request.path)
and not request.path.startswith(clientPrefix)
and len(list(filter(lambda x : x not in request.path, whiteList))) == len(whiteList) and len(list(filter(lambda x : x not in request.path, whiteList))) == len(whiteList)
): ):
response = Flask.make_response(app, { response = Flask.make_response(app, {