diff --git a/server/wsi_viewer/desktop_routes.py b/server/wsi_viewer/desktop_routes.py index 6572aa46..f064dc20 100644 --- a/server/wsi_viewer/desktop_routes.py +++ b/server/wsi_viewer/desktop_routes.py @@ -50,7 +50,7 @@ from .domain import SlideState from .evidence_contract import load_trusted_signers, parse_evidence, validate_evidence from .evidence_set_contract import validate_evidence_set -from .identity import is_default_legacy_owner +from .identity import DEFAULT_ORGANIZATION_ID, is_default_legacy_owner from .models import ( AnalysisRun, Annotation, @@ -683,6 +683,9 @@ def credential_status( authenticated: DesktopCredential = Depends(credential), ) -> dict[str, Any]: return { + "organizationId": DEFAULT_ORGANIZATION_ID, + "userId": authenticated.user_id, + "credentialId": authenticated.id, "deviceName": authenticated.device_name, "scopes": authenticated.scopes, "expiresAt": as_utc(authenticated.expires_at).isoformat(), diff --git a/tests/backend/test_api.py b/tests/backend/test_api.py index e10e491a..f6f09fcb 100644 --- a/tests/backend/test_api.py +++ b/tests/backend/test_api.py @@ -26,7 +26,7 @@ from wsi_viewer.config import Settings from wsi_viewer.database import create_schema, session_factory from wsi_viewer.domain import SlideState -from wsi_viewer.identity import ensure_default_owner_membership +from wsi_viewer.identity import DEFAULT_ORGANIZATION_ID, ensure_default_owner_membership from wsi_viewer.main import create_app from wsi_viewer.models import ( AnalysisRun, @@ -497,7 +497,16 @@ def test_desktop_pairing_is_short_lived_one_time_and_revocable(tmp_path: Path) - "persistedSha256": True, } ] - assert client.get("/api/v1/desktop/credential", headers=authorization).status_code == 200 + credential_status = client.get("/api/v1/desktop/credential", headers=authorization) + assert credential_status.status_code == 200 + status_body = credential_status.json() + assert status_body["organizationId"] == DEFAULT_ORGANIZATION_ID + with session_factory(client.app.state.settings)() as database: + stored = database.scalar(select(DesktopCredential)) + assert stored is not None + assert status_body["userId"] == stored.user_id + assert status_body["credentialId"] == stored.id + assert "accessToken" not in status_body assert ( client.post("/api/v1/desktop/credential/revoke", headers=authorization).status_code == 204