Skip to content

Open-source personal finance manager. Self-hosted, privacy-first.

fix(auth): make the Swagger token URL absolute (#1209)

Carson Jones25132267ae11
diff --git a/backend/app/core/auth.py b/backend/app/core/auth.py
index e7730606..81ed08bd 100644
--- a/backend/app/core/auth.py
+++ b/backend/app/core/auth.py
@@ -81,7 +81,7 @@ async def get_user_manager(user_db: SQLAlchemyUserDatabase = Depends(get_user_db
yield UserManager(user_db)
-bearer_transport = BearerTransport(tokenUrl="api/auth/login")
+bearer_transport = BearerTransport(tokenUrl="/api/auth/login")
def get_jwt_strategy() -> JWTStrategy:
diff --git a/backend/tests/test_auth_api.py b/backend/tests/test_auth_api.py
index 6d2e4b27..84cef8d6 100644
--- a/backend/tests/test_auth_api.py
+++ b/backend/tests/test_auth_api.py
@@ -64,6 +64,13 @@ async def test_get_me_unauthenticated(client: AsyncClient, clean_db):
assert response.status_code == 401
+async def test_openapi_token_url_is_absolute(client: AsyncClient):
+ response = await client.get("/api/openapi.json")
+ flows = response.json()["components"]["securitySchemes"]["OAuth2PasswordBearer"]["flows"]
+ assert flows["password"]["tokenUrl"] == "/api/auth/login"
+
+
@pytest.mark.asyncio
async def test_login_forbidden_when_local_auth_disabled(client: AsyncClient, test_user, oidc_only_settings):
response = await client.post(