Files
zyt/artifacts/esign-identity-binding-desktop.md
T
2026-11-20 10:30:04 +08:00

4.3 KiB

Desktop supplementary certificate identity binding

Implemented 2026-11-18 in the existing in-system prescription signature dialog.

Behavior and contract

  • esign_identity_status accepts optional identity_details_required and normalizes an absent field to False. Present values must be booleans. A true value is accepted only with identity_status=SUCCESS, status=authenticating, enabled/required/can_sign all true, and can_complete=False. Conflicting flags fail closed. The client never changes can_complete to authorize signing.
  • Only the validated identity-readiness GET can expose the supplementary form. Ordinary signature status responses cannot do so. The dialog stops its timer, drops the previous signing intent, and disposes the embedded authentication view while awaiting input.
  • The form explains one-time certificate binding and the requirement to match the completed authentication. It uses a password-mode QLineEdit with sensitive input hints and the explicit action 绑定证书并签署. Enter in the input does not submit binding.
  • Input validation accepts the ASCII shape of legacy 15-digit or modern 18-character mainland identity numbers, with an optional final X in the latter. Client validation does not establish identity; server date/checksum/authentication matching remains authoritative.
  • Submission clears the input before asynchronous dispatch and sets the existing one-completion latch first. Invalid input clears the entry and stays in the form without dispatch. Cancel, refresh, hide, reject, and close clear the entry. No identity value is added to dialog state, persisted, or logged by this change.
  • DoctorRepository, RemoteDoctorRepository, and the demo repository accept complete_prescription_esign(prescription_id, identity_number=""). An absent number preserves the original one-argument/no-extra-field behavior. A supplied number is sent only in the existing completion POST body. Existing API transport behavior already prevents POST retry; no ApiClient change was needed for this task.
  • Completion timeout or ambiguity keeps the latch set. Manual refresh cannot repeat signing within the same dialog. Generation and deadline checks reject stale callbacks. Existing Qt native initialization hide/show handling is retained.

Verification

From D:\web\zyt\app:

& .venv/Scripts/python.exe -m pytest tests/test_prescription_esign.py tests/test_esign_webview.py tests/test_esign_native_lifecycle.py tests/test_repository_parity.py tests/test_api_client.py --basetemp=.pytest-tmp-esign-identity-binding-final

Result: 191 passed, 2 skipped in 4.43 seconds. The skipped cases are opt-in native Qt tests. Coverage includes required-input/no-auto-sign, one explicit completion, input clearing before dispatch and across lifecycle changes, invalid shape rejection, conflicting capabilities, legacy DTO compatibility, stale callbacks, timeout uncertainty, body-only identity transmission, no POST retry, repository parity, and existing embedded-browser behavior.

Ruff passed for all modified Python files. git diff --check passed for the modified desktop files.

Real Windows Qt verification used ESIGN_NATIVE_QT_TEST=1, QT_QPA_PLATFORM=windows, and the existing test_esign_native_lifecycle.py. Each parameterized case passed in its own process outside the process-restricted sandbox: normal native recreation 1 passed in 3.34 seconds; genuine user hide 1 passed in 2.83 seconds. These tests use a fake repository and replace provider URL loading.

The sandbox native run aborted while initializing WebEngine. An elevated combined run reached both passing assertion markers but exited with code 1 before pytest's final summary; it is not counted as a clean combined pass. The isolated native runs completed with exit code 0. No test or application native-lifecycle implementation was changed to suppress that behavior.

Scope

Changed only desktop core validation, repository interfaces/implementation, signature dialog, tests, and this report. Preserved the existing user change to app/src/doctor_workstation/__init__.py. No provider requests, real identity numbers, signing operations, or business database operations were used for this work. The live wrapper and server implementation are separate deliverables; this report does not claim an end-to-end live signature succeeded.