Synav commited on
Commit
c4be9bf
·
verified ·
1 Parent(s): f7e61c3

Delete app/auth_gate.py

Browse files
Files changed (1) hide show
  1. app/auth_gate.py +0 -76
app/auth_gate.py DELETED
@@ -1,76 +0,0 @@
1
- """
2
- Access gate for GVHD-Intel Pro: login + research-use-only acknowledgement.
3
-
4
- Credentials come from the Space secret APP_USERS, formatted as
5
- user1:password1,user2:password2
6
- (no commas or colons inside passwords).
7
-
8
- Usage (top of app.py and of EVERY file in pages/, right after st.set_page_config):
9
- from auth_gate import require_access
10
- require_access()
11
- """
12
- import os
13
- import datetime
14
-
15
- import streamlit as st
16
-
17
-
18
- def _load_users() -> dict:
19
- raw = os.environ.get("APP_USERS", "")
20
- return dict(u.strip().split(":", 1) for u in raw.split(",") if ":" in u)
21
-
22
-
23
- def require_access() -> None:
24
- users = _load_users()
25
-
26
- # ---------- Step 1: login ----------
27
- if not st.session_state.get("authed"):
28
- st.title("🧬 GVHD-Intel Pro — Research Access")
29
- st.caption(
30
- "Access is restricted to registered research users. "
31
- "Credentials are issued by the study team (naveed3642003@gmail.com)."
32
- )
33
- with st.form("login_form"):
34
- u = st.text_input("Username")
35
- p = st.text_input("Password", type="password")
36
- ok = st.form_submit_button("Log in")
37
- if ok:
38
- if users and users.get(u) == p:
39
- st.session_state.authed = True
40
- st.session_state.user = u
41
- print(f"[ACCESS] {datetime.datetime.utcnow().isoformat()}Z user={u} login ok", flush=True)
42
- st.rerun()
43
- else:
44
- print(f"[ACCESS] {datetime.datetime.utcnow().isoformat()}Z user={u} login FAILED", flush=True)
45
- st.error("Invalid username or password.")
46
- st.stop()
47
-
48
- # ---------- Step 2: research-use acknowledgement ----------
49
- if not st.session_state.get("accepted"):
50
- st.title("Research Use Only")
51
- st.warning(
52
- "This tool is provided for research purposes only. It is **not a medical device**, "
53
- "has **not been validated for clinical use**, and must **not** be used to make or change "
54
- "diagnostic, donor-selection, prophylaxis or treatment decisions, or for patient counselling.\n\n"
55
- "In external evaluation, acute GVHD discrimination was close to chance (AUROC ≈0.52–0.57), "
56
- "chronic GVHD discrimination was modest (AUROC 0.54–0.64), and calibration drifted across cohorts. "
57
- "Predicted percentages are not reliable absolute risks.\n\n"
58
- "**Do not enter identifiable patient information** (names, MRNs, exact dates of birth)."
59
- )
60
- agree = st.checkbox("I understand and agree to use this tool for research purposes only.")
61
- if st.button("Continue", disabled=not agree, type="primary"):
62
- st.session_state.accepted = True
63
- print(
64
- f"[ACCESS] {datetime.datetime.utcnow().isoformat()}Z "
65
- f"user={st.session_state.user} accepted research-use terms",
66
- flush=True,
67
- )
68
- st.rerun()
69
- st.stop()
70
-
71
- # ---------- Logged in: show user + logout ----------
72
- with st.sidebar:
73
- st.caption(f"Signed in as **{st.session_state.user}**")
74
- if st.button("Log out", key="logout_btn"):
75
- st.session_state.clear()
76
- st.rerun()