From c1e679cc2841bae2b4608b991d0d7ec3b7fbed7f Mon Sep 17 00:00:00 2001 From: vprusakovs Date: Tue, 7 Feb 2023 15:50:13 +0200 Subject: [PATCH] 1.0.2 (2023-02-07) ------------------ * [fix] ccsrftoken for fortios v7 --- fortigate_api/fortigate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fortigate_api/fortigate.py b/fortigate_api/fortigate.py index 922297a9..df77d6c6 100644 --- a/fortigate_api/fortigate.py +++ b/fortigate_api/fortigate.py @@ -157,7 +157,7 @@ def login(self) -> None: raise self._hide_secret_ex(ex) cookie_name = "ccsrftoken" - cookies = [o for o in session.cookies if o.name == cookie_name] + cookies = [o for o in session.cookies if o and o.name == cookie_name] if not cookies: regex = cookie_name + r"_\d+$" cookies = [o for o in session.cookies if re.match(regex, o.name)] @@ -165,7 +165,7 @@ def login(self) -> None: if not cookies: raise ValueError("invalid login credentials, absent cookie ccsrftoken") cookie = cookies[0] - token = cookie.value.strip("\"") + token = str(cookie.value).strip("\"") session.headers.update({"X-CSRFTOKEN": token}) response: Response = session.get(url=f"{self.url}/api/v2/cmdb/system/vdom")