Skip to content

Commit 133dea1

Browse files
committed
fix: increase WebVPN timeouts from 30s to 60s for reliability
1 parent 57e3f87 commit 133dea1

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/api/webvpn.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def authenticate_icourse(
199199
vpn_url = get_vpn_url(casapi_url)
200200

201201
# Follow redirect chain to reach IDP login page and extract lck
202-
resp = self.session.get(vpn_url, allow_redirects=False, timeout=30)
202+
resp = self.session.get(vpn_url, allow_redirects=False, timeout=60)
203203
lck = None
204204
for _ in range(15):
205205
location = resp.headers.get("Location", "")
@@ -212,7 +212,7 @@ def authenticate_icourse(
212212
if not location.startswith("http"):
213213
location = urljoin(resp.url, location)
214214
resp = self.session.get(
215-
location, allow_redirects=False, timeout=30
215+
location, allow_redirects=False, timeout=60
216216
)
217217

218218
if not lck:
@@ -241,7 +241,7 @@ def authenticate_icourse(
241241
"Referer": f"{idp_vpn_base}/ac/",
242242
"Origin": config.WEBVPN_BASE,
243243
},
244-
timeout=30,
244+
timeout=60,
245245
)
246246
data = resp.json()
247247
auth_method_list = data.get("data", [])
@@ -262,7 +262,7 @@ def authenticate_icourse(
262262
resp = self.session.get(
263263
url,
264264
headers={"Referer": f"{idp_vpn_base}/ac/"},
265-
timeout=30,
265+
timeout=60,
266266
)
267267
data = resp.json()
268268
pub_key_b64 = data.get("data", "")
@@ -297,7 +297,7 @@ def authenticate_icourse(
297297
"Referer": f"{idp_vpn_base}/ac/",
298298
"Origin": config.WEBVPN_BASE,
299299
},
300-
timeout=30,
300+
timeout=60,
301301
)
302302
data = resp.json()
303303

@@ -321,7 +321,7 @@ def authenticate_icourse(
321321
"Referer": f"{idp_vpn_base}/ac/",
322322
"Origin": config.WEBVPN_BASE,
323323
},
324-
timeout=30,
324+
timeout=60,
325325
)
326326
html = resp.text
327327

@@ -356,7 +356,7 @@ def authenticate_icourse(
356356
test_url = get_vpn_url(
357357
f"{config.ICOURSE_BASE}/userapi/v1/infosimple"
358358
)
359-
resp = self.session.get(test_url, timeout=30)
359+
resp = self.session.get(test_url, timeout=60)
360360
if resp.status_code == 200:
361361
try:
362362
user_data = resp.json()
@@ -401,12 +401,12 @@ def _get_auth_context(self) -> tuple[str, str]:
401401
f"{config.IDP_BASE}/idp/authCenter/authenticate"
402402
f"?service={quote(service_url, safe='')}"
403403
)
404-
resp = self.session.get(url, allow_redirects=False, timeout=30)
404+
resp = self.session.get(url, allow_redirects=False, timeout=60)
405405

406406
# Follow redirects manually to extract lck
407407
location = resp.headers.get("Location", "")
408408
while resp.status_code in (301, 302) and "lck=" not in location:
409-
resp = self.session.get(location, allow_redirects=False, timeout=30)
409+
resp = self.session.get(location, allow_redirects=False, timeout=60)
410410
location = resp.headers.get("Location", "")
411411

412412
if resp.status_code in (301, 302):
@@ -437,7 +437,7 @@ def _query_auth_methods(
437437
"Referer": f"{config.IDP_BASE}/ac/",
438438
"Origin": config.IDP_BASE,
439439
},
440-
timeout=30,
440+
timeout=60,
441441
)
442442
data = resp.json()
443443

@@ -467,7 +467,7 @@ def _get_public_key(self) -> str:
467467
headers={
468468
"Referer": f"{config.IDP_BASE}/ac/",
469469
},
470-
timeout=30,
470+
timeout=60,
471471
)
472472
data = resp.json()
473473
pub_key_b64 = data.get("data", "")
@@ -521,7 +521,7 @@ def _auth_execute(
521521
"Referer": f"{config.IDP_BASE}/ac/",
522522
"Origin": config.IDP_BASE,
523523
},
524-
timeout=30,
524+
timeout=60,
525525
)
526526
data = resp.json()
527527

@@ -548,7 +548,7 @@ def _get_cas_ticket(self, login_token: str) -> str:
548548
"Referer": f"{config.IDP_BASE}/ac/",
549549
"Origin": config.IDP_BASE,
550550
},
551-
timeout=30,
551+
timeout=60,
552552
)
553553

554554
# The response is HTML containing a JS redirect with the ticket URL

0 commit comments

Comments
 (0)