🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Fix SSO login: make the auth-redirect page-load callback async
Omega (QA)431be785994e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5d986d7..7d98d13 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -74,6 +74,8 @@- _Files: `frontend/js/components/importExport.js`, `frontend/status.js`, `tests/test_csv_formula_neutralization.py`_- **Security hardening, CSV and claim dates:** the importer and the claim endpoints accepted anything the date parser would read, so "03/04/2024" silently became March 4 (month-first). Only ISO YYYY-MM-DD and named-month dates are accepted now (15 Mar 2024, 15 March 2024, Mar 15, 2024, March 15, 2024, and the comma-less variants). Anything else, including ambiguous numeric dates, is rejected with an error naming the accepted formats. Imports that relied on flexible numeric dates need their dates rewritten.- _Files: `backend/warranties_routes.py`, `tests/test_csv_date_formats.py`_+- **SSO login fixed:** the single-use code exchange added for OIDC sign-in used `await` inside a plain (non-async) page-load callback, so the whole login redirect script failed to parse and sign-in through an identity provider stalled at "Authenticating, please wait..." with no error shown. The callback is now async, so the code exchange runs, the token and user info are stored, and sign-in completes. The no-params fallback redirect to the login page works again too.+ - _Files: `frontend/auth-redirect.html`, `tests/test_auth_redirect_script.py`_## 1.0.6 - 2026-11-10diff --git a/frontend/auth-redirect.html b/frontend/auth-redirect.htmlindex cb9c157..64def49 100644--- a/frontend/auth-redirect.html+++ b/frontend/auth-redirect.html@@ -91,7 +91,7 @@}}- document.addEventListener('DOMContentLoaded', function() {+ document.addEventListener('DOMContentLoaded', async function() {const statusMessage = document.getElementById('statusMessage');const errorMessageEl = document.getElementById('errorMessage');const loginLink = document.getElementById('loginLink');diff --git a/tests/test_auth_redirect_script.py b/tests/test_auth_redirect_script.pynew file mode 100644index 0000000..4728ea3--- /dev/null+++ b/tests/test_auth_redirect_script.py@@ -0,0 +1,41 @@+"""AUTH-03: auth-redirect.html inline script must parse.++ba00a85 put an `await` inside a plain (non-async) DOMContentLoaded+callback, so the whole inline script failed to parse and OIDC SSO+stalled at "Authenticating, please wait...". The callback must stay+async, and the page's inline scripts must keep passing node --check.+"""+import re+import shutil+import subprocess+import tempfile+from pathlib import Path++import pytest++PAGE = Path(__file__).resolve().parent.parent / "frontend" / "auth-redirect.html"+++def _inline_scripts():+ html = PAGE.read_text()+ return re.findall(r"<script>(.*?)</script>", html, re.S)+++def test_auth_redirect_callback_is_async():+ html = PAGE.read_text()+ assert "addEventListener('DOMContentLoaded', async function" in html+++def test_auth_redirect_inline_scripts_parse():+ node = shutil.which("node")+ if node is None:+ pytest.skip("node is not installed")+ scripts = _inline_scripts()+ assert scripts, "no inline scripts found in auth-redirect.html"+ with tempfile.NamedTemporaryFile(+ "w", suffix=".js", delete=False) as tmp:+ tmp.write("\n;\n".join(scripts))+ path = tmp.name+ r = subprocess.run([node, "--check", path],+ capture_output=True, text=True)+ assert r.returncode == 0, r.stderr