Skip to content

Commit

Permalink
Merge pull request #125 from uclahs-cds/aholmes-add-requests-timeout
Browse files Browse the repository at this point in the history
Resolve Bandit warnings regarding `requests` timeout.
  • Loading branch information
aholmes authored Sep 26, 2024
2 parents 42ee6e7 + 710f949 commit 229d129
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/identity/Ligare/identity/SAML2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from saml2.client import Saml2Client as PySaml2Client
from saml2.config import Config as PySaml2Config

_SAML2_REQUESTS_TIMEOUT = 10


class SAML2Client:
"""
Expand Down Expand Up @@ -38,7 +40,10 @@ def _get_saml_client(self, serialized_settings: bytes):
override_settings = loads(serialized_settings)

if not self._metadata and self._metadata_url:
rv: Response = cast(Response, requests.get(self._metadata_url)) # pyright: ignore[reportUnnecessaryCast] - pyright cli reports this is unnecessary, but vscode extension says otherwise
rv: Response = cast(
Response,
requests.get(self._metadata_url, timeout=_SAML2_REQUESTS_TIMEOUT),
) # pyright: ignore[reportUnnecessaryCast]
self._metadata = rv.text

if not self._metadata:
Expand Down

0 comments on commit 229d129

Please sign in to comment.