Hide admin tab behind password gate; fix import-time env read
Browse files- ADMIN_PASSWORD now read dynamically via _get_admin_password()
(same pattern as _get_master_key()) to fix stale env var issue
- Admin tab hidden by default (visible=False); revealed only after
entering correct password via "Maintainer Access" in About tab
- Regular users see no admin UI
app.py
CHANGED
|
@@ -796,6 +796,16 @@ def admin_view_key_requests(password: str) -> str:
|
|
| 796 |
return "\n".join(lines)
|
| 797 |
|
| 798 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 799 |
# ---------------------------------------------------------------------------
|
| 800 |
# Gradio UI
|
| 801 |
# ---------------------------------------------------------------------------
|
|
@@ -1381,13 +1391,16 @@ contact details.
|
|
| 1381 |
"- [Project Website](https://sites.google.com/view/st-webagentbench/home)"
|
| 1382 |
)
|
| 1383 |
|
| 1384 |
-
|
| 1385 |
-
|
| 1386 |
-
|
| 1387 |
-
|
|
|
|
| 1388 |
|
| 1389 |
-
|
| 1390 |
-
|
|
|
|
|
|
|
| 1391 |
|
| 1392 |
with gr.Accordion("Remove Submission", open=True):
|
| 1393 |
admin_agent_id = gr.Textbox(label="Agent ID to remove")
|
|
@@ -1415,6 +1428,14 @@ contact details.
|
|
| 1415 |
api_name=False,
|
| 1416 |
)
|
| 1417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1418 |
return demo
|
| 1419 |
|
| 1420 |
|
|
|
|
| 796 |
return "\n".join(lines)
|
| 797 |
|
| 798 |
|
| 799 |
+
def admin_login(password: str):
|
| 800 |
+
"""Validate admin password and return visibility update for admin tab."""
|
| 801 |
+
admin_pw = _get_admin_password()
|
| 802 |
+
if not admin_pw:
|
| 803 |
+
return gr.update(visible=False), "Admin not configured."
|
| 804 |
+
if password != admin_pw:
|
| 805 |
+
return gr.update(visible=False), "Invalid password."
|
| 806 |
+
return gr.update(visible=True), "Access granted."
|
| 807 |
+
|
| 808 |
+
|
| 809 |
# ---------------------------------------------------------------------------
|
| 810 |
# Gradio UI
|
| 811 |
# ---------------------------------------------------------------------------
|
|
|
|
| 1391 |
"- [Project Website](https://sites.google.com/view/st-webagentbench/home)"
|
| 1392 |
)
|
| 1393 |
|
| 1394 |
+
# Hidden admin gate at bottom of About tab
|
| 1395 |
+
with gr.Accordion("Maintainer Access", open=False, visible=True):
|
| 1396 |
+
admin_login_pw = gr.Textbox(label="Password", type="password")
|
| 1397 |
+
admin_login_btn = gr.Button("Login", size="sm")
|
| 1398 |
+
admin_login_msg = gr.Textbox(label="Status", interactive=False, lines=1)
|
| 1399 |
|
| 1400 |
+
# ---- Hidden admin panel (not a visible tab) ----
|
| 1401 |
+
# Access via password gate only — no "Admin" tab shown to users.
|
| 1402 |
+
with gr.TabItem("Admin", visible=False) as admin_tab:
|
| 1403 |
+
gr.Markdown("### Administration")
|
| 1404 |
|
| 1405 |
with gr.Accordion("Remove Submission", open=True):
|
| 1406 |
admin_agent_id = gr.Textbox(label="Agent ID to remove")
|
|
|
|
| 1428 |
api_name=False,
|
| 1429 |
)
|
| 1430 |
|
| 1431 |
+
# Wire admin login button (must be after admin_tab is defined)
|
| 1432 |
+
admin_login_btn.click(
|
| 1433 |
+
admin_login,
|
| 1434 |
+
inputs=[admin_login_pw],
|
| 1435 |
+
outputs=[admin_tab, admin_login_msg],
|
| 1436 |
+
api_name=False,
|
| 1437 |
+
)
|
| 1438 |
+
|
| 1439 |
return demo
|
| 1440 |
|
| 1441 |
|