From b305e1ce2337399b233daf3c881e43308ce065f3 Mon Sep 17 00:00:00 2001 From: Nikolas Heise Date: Tue, 22 Apr 2025 13:30:32 +0200 Subject: [PATCH] Fix login using the native ilias login form --- CHANGELOG.md | 3 +++ PFERD/crawl/ilias/ilias_web_crawler.py | 12 +++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bc00b6..0e8dc10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,9 @@ ambiguous situations. ## Changed - Explicitly mention that wikis are not supported at the moment and ignore them +## Fixed +- Ilias-native login + ## 3.8.1 - 2025-04-17 ## Fixed diff --git a/PFERD/crawl/ilias/ilias_web_crawler.py b/PFERD/crawl/ilias/ilias_web_crawler.py index 8ba959a..48396f9 100644 --- a/PFERD/crawl/ilias/ilias_web_crawler.py +++ b/PFERD/crawl/ilias/ilias_web_crawler.py @@ -1039,7 +1039,7 @@ instance's greatest bottleneck. async with self.session.get(urljoin(self._base_url, "/login.php"), params=params) as request: login_page = soupify(await request.read()) - login_form = cast(Optional[Tag], login_page.find("form", attrs={"name": "formlogin"})) + login_form = cast(Optional[Tag], login_page.find("form", attrs={"name": "login_form"})) if login_form is None: raise CrawlError("Could not find the login form! Specified client id might be invalid.") @@ -1049,14 +1049,12 @@ instance's greatest bottleneck. username, password = await self._auth.credentials() - login_data = { - "username": username, - "password": password, - "cmd[doStandardAuthentication]": "Login", - } + login_form_data = aiohttp.FormData() + login_form_data.add_field('login_form/input_3/input_4', username) + login_form_data.add_field('login_form/input_3/input_5', password) # do the actual login - async with self.session.post(urljoin(self._base_url, login_url), data=login_data) as request: + async with self.session.post(urljoin(self._base_url, login_url), data=login_form_data) as request: soup = IliasSoup(soupify(await request.read()), str(request.url)) if not IliasPage.is_logged_in(soup): self._auth.invalidate_credentials()