Merge pull request #19 from cadtoolbox/copilot/fix-advanced-auth-errors

This commit is contained in:
Thomas Rambach
2026-02-09 04:35:24 -05:00
committed by GitHub
2 changed files with 29 additions and 0 deletions
+2
View File
@@ -2636,6 +2636,8 @@ PUBLIC_API_ROUTES = {
"/api/v1/auth/status",
"/api/v1/auth/login",
"/api/v1/auth/setup", # Needed for initial setup and recovery
"/api/v1/auth/advanced-auth/status", # Advanced auth status needed for login page
"/api/v1/auth/forgot-password", # Password reset for advanced auth
# Version check for updates (no sensitive data)
"/api/v1/updates/version",
# Metrics endpoint handles its own prometheus_token authentication
@@ -774,3 +774,30 @@ class TestAuthMiddlewarePublicRoutes:
headers={"Authorization": f"Bearer {token}"},
)
assert response.status_code == 200
@pytest.mark.asyncio
@pytest.mark.integration
async def test_advanced_auth_status_is_public(self, async_client: AsyncClient, enabled_auth):
"""Verify /api/v1/auth/advanced-auth/status is accessible without auth."""
response = await async_client.get("/api/v1/auth/advanced-auth/status")
# Should not be 401 (must be accessible for login page)
assert response.status_code != 401
# Should return valid response (200 with auth status)
if response.status_code == 200:
result = response.json()
assert "advanced_auth_enabled" in result
assert "smtp_configured" in result
@pytest.mark.asyncio
@pytest.mark.integration
async def test_forgot_password_is_public(self, async_client: AsyncClient, enabled_auth):
"""Verify /api/v1/auth/forgot-password is accessible without auth."""
response = await async_client.post(
"/api/v1/auth/forgot-password",
json={"email": "test@example.com"},
)
# Should not be 401 (must be accessible for password reset from login page)
assert response.status_code != 401
# Will likely be 400 (advanced auth not enabled) but that's okay -
# the important thing is it's not blocked by auth middleware
assert response.status_code in [200, 400]