From b994993daf8d7421068ff0de0ff68893f215cc46 Mon Sep 17 00:00:00 2001 From: Daniel Dayley Date: Thu, 7 Nov 2024 10:09:07 -0700 Subject: [PATCH] Fixed access logic --- bin/headercheckdashboardproxy | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/headercheckdashboardproxy b/bin/headercheckdashboardproxy index 821b372..b71631e 100644 --- a/bin/headercheckdashboardproxy +++ b/bin/headercheckdashboardproxy @@ -48,21 +48,24 @@ async def serve_file(request: Request, file_path: str) : raw_markup = html = open(os.path.join(base_path, index_file)) soup = BeautifulSoup(raw_markup, 'html.parser') for service in soup.find_all("li", class_='service') : + shouldremove = false if 'users' in service.attrs.keys() : allowed_users = service['users'].split(',') if allowed_users != ["Any"] and user_header not in allowed_users : - service.decompose() - continue + shouldremove = true if 'groups' in service.attrs.keys() : allowed_groups = service['groups'].split(',') if list(set(current_groups) & set(allowed_groups)) == [] : - service.decompose() + shouldremove = true + else : + shouldremove = false + if shouldremove : + service.decompose() for category in soup.select('li.category:not(:has(ul li))') : category.decompose() byte_stream = io.BytesIO(soup.encode('utf-8')) byte_stream.seek(0) return StreamingResponse(byte_stream, media_type="text/html") -# return FileResponse(byte_stream, media_type="text/html", filename="index.html") if file_to_serve.is_dir(): raise HTTPException(status_code=404, detail="Not Found") elif file_to_serve.is_file():