Skip to content

Commit

Permalink
Increase the default timeout to 15s
Browse files Browse the repository at this point in the history
  • Loading branch information
csc-felipe committed Jun 10, 2024
1 parent adb7a8e commit 9094eeb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ def make_oidc_url(path: str) -> str:

CONFIG["url_oidc"] = make_oidc_url(CONFIG["oidc_config_path"])

default_timeout = httpx.Timeout(15.0, read=60.0)

def get_configs():
"""Request OpenID configuration from OpenID provider."""
with httpx.Client(verify=False) as client:
with httpx.Client(verify=False, timeout=default_timeout) as client:
LOG.debug(f"requesting OpenID configuration from {CONFIG['url_oidc']}")
response = client.get(CONFIG["url_oidc"])
if response.status_code == 200:
Expand Down Expand Up @@ -280,7 +281,7 @@ async def request_tokens(code: str) -> Tuple[str, str]:
data = {"grant_type": "authorization_code", "code": code, "redirect_uri": CONFIG["url_callback"]}
LOG.debug(f"post payload: {data}")

async with httpx.AsyncClient(auth=auth, verify=False) as client:
async with httpx.AsyncClient(auth=auth, verify=False, timeout=default_timeout) as client:
# request tokens
LOG.debug("requesting tokens to: %r, with data %r", CONFIG["url_token"], data)

Expand All @@ -306,7 +307,7 @@ async def revoke_token(token: str) -> None:
auth = httpx.BasicAuth(username=CONFIG["client_id"], password=CONFIG["client_secret"])
params = {"token": token}

async with httpx.AsyncClient(auth=auth, verify=False) as client:
async with httpx.AsyncClient(auth=auth, verify=False, timeout=default_timeout) as client:
# send request to AAI
response = await client.get(CONFIG["url_revoke"] + "?" + urlencode(params))
if response.status_code == 200:
Expand Down Expand Up @@ -335,7 +336,7 @@ async def userinfo_endpoint(access_token: str = Cookie("")):
"Authorization": f"Bearer {access_token}",
}

async with httpx.AsyncClient(headers=headers, verify=False) as client:
async with httpx.AsyncClient(headers=headers, verify=False, timeout=default_timeout) as client:
# request tokens
LOG.debug("requesting userinfo")
response = await client.post(CONFIG["url_userinfo"])
Expand Down

0 comments on commit 9094eeb

Please sign in to comment.