From c7b7e949dafdc01c126f8b39402053f34268c0a2 Mon Sep 17 00:00:00 2001 From: Hendrik Wolff Date: Tue, 3 Sep 2024 18:33:27 +0200 Subject: [PATCH] ipd: Fix checking for totp type (#148) * ipd: Fix checking for totp type The idp frontend HTML structure changed recently and broke the check for totp vs iotp. This caused a failed totp insertion, resulting in an incomplete authentication. * npm run test --- src/background.ts | 6 +++--- src/contentScripts/login/idp.ts | 4 +++- src/freshContent/settings/settingPages/AutoLogin.vue | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/background.ts b/src/background.ts index a96cb84..a438f72 100644 --- a/src/background.ts +++ b/src/background.ts @@ -222,11 +222,11 @@ chrome.runtime.onMessage.addListener((request, _sender, sendResponse) => { // Asynchronous response Promise.all([ credentials.userDataExists(request.platform), - credentials.userDataExists(request.platform + "-totp"), - credentials.userDataExists(request.platform + "-iotp") + credentials.userDataExists(request.platform + '-totp'), + credentials.userDataExists(request.platform + '-iotp') ]).then(([loginExists, totpExists, iotpExists]) => { sendResponse(loginExists || totpExists || iotpExists) - }); + }) return true // required for async sendResponse case 'delete_user_data': // Asynchronous response diff --git a/src/contentScripts/login/idp.ts b/src/contentScripts/login/idp.ts index ccb4071..483b3a9 100644 --- a/src/contentScripts/login/idp.ts +++ b/src/contentScripts/login/idp.ts @@ -61,7 +61,9 @@ const cookieSettings: CookieSettings = { const otpInput = document.getElementById('fudis_otp_input') as HTMLInputElement | null if (otpInput) { - const indexesText = otpInput.parentElement?.parentElement?.querySelector('td:first-of-type')?.textContent?.trim() + const indexesText = otpInput.parentElement?.parentElement?.parentElement + ?.querySelector('div:first-of-type') + ?.textContent?.trim() // find number & number | remove whole match | to numbers | to zero based (first index is 0) const indexes = indexesText?.match(/(\d+) & (\d+)/)?.slice(1, 3).map((x) => Number.parseInt(x, 10) - 1) diff --git a/src/freshContent/settings/settingPages/AutoLogin.vue b/src/freshContent/settings/settingPages/AutoLogin.vue index a33c6aa..c37b1c7 100644 --- a/src/freshContent/settings/settingPages/AutoLogin.vue +++ b/src/freshContent/settings/settingPages/AutoLogin.vue @@ -49,7 +49,10 @@ Zwei-Faktor-Authentisierung (2FA): Das Automatische Anmelden unterstützt auch 2FA. Hier kannst du dafür deinen TOTP Secret-Key speichern. Der Key ist Base32 enkodiert und sieht bspw. so aus:
MHSTKUIKTTHPQAZNVWQBJE5YQ2WACQQP
- Hier findest du mehr Informationen und eine vollständige Anleitung zur Einrichtung. + Hier findest du mehr Informationen und eine vollständige Anleitung zur Einrichtung.