Skip to content

Commit

Permalink
1.0.2 (2023-02-07)
Browse files Browse the repository at this point in the history
------------------
* [fix] ccsrftoken for fortios v7
  • Loading branch information
vprusakovs committed Feb 7, 2023
1 parent ec28cbb commit c1e679c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fortigate_api/fortigate.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ 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)]
cookies = [o for o in cookies if isinstance(o.value, str)]
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")
Expand Down

0 comments on commit c1e679c

Please sign in to comment.