Project

General

Profile

Actions

Feature #143

open
SV SV

[HR][P5] Documents

Feature #143: [HR][P5] Documents

Added by Sravan V S about 2 months ago. Updated 3 days ago.

Status:
Resolved
Priority:
High
Assignee:
Target version:
-
Start date:
09/28/2026
Due date:
% Done:

0%

Estimated time:
Resolved By:

Description

Add a download endpoint that goes through the portal proxy; stop returning raw Azure SAS URLs to the browser. Model generated letters and photos as document rows. Canonical hr.documents table + IDocumentStorage. Upload error mapping. Credential evidence modeled as documents.

Size: L

Source: clinq-docs/modules/hr/reviews/2026-09-28-ui-audit/ (branch docs/hr-ui-audit-2026-09-28)

Findings covered:

  • D-32
  • D-33
  • D-34
  • D-35
  • D-36
  • D-26
  • D-38

SV Updated by Sravan V S about 2 months ago Actions #1

  • Assignee set to Sravan V S

S- Updated by SK - 13 days ago Actions #2

  • Assignee changed from Sravan V S to SK -

S- Updated by SK - 13 days ago Actions #3

  • Status changed from New to Resolved
  • Assignee changed from SK - to Roshni Harish.
  • Resolved By set to SK -

Fixed and merged to dev on nuvita-hr, plus a load-bearing companion permission-seed change on nuvita-admin (merged together) - the ticket renamed HR's document permission keys, so without the companion change every role holding the old keys would have silently lost document access.

Confirmed the core security issue directly: every file-serving path (employee documents, generated letters, employee photos) returned a freshly-generated Azure SAS URL straight to the browser, bypassing the portal's own auth/audit layer entirely - anyone who got hold of a URL could access the file with no permission check. Also confirmed HR had no canonical documents table at all; what existed was an ad-hoc parallel storage mechanism, not the platform's established pattern (the same divergence #142 flagged in passing).

Built hr.documents as a proper canonical table, column-for-column matching EMR's reference implementation of the platform's documents pattern, wired through the shared IDocumentStorage abstraction - and removed the old parallel storage mechanism entirely, no trace left. No endpoint returns a bare file URL anymore; every download now streams through a permission-checked endpoint.

Migrated generated letters and new employee-photo uploads fully onto the new table. Credential evidence got an upload-and-attach option added to the existing detail view (the create flow still only offers the old free-text link for now - flagging as a reasonable scope cut, since attaching a file requires the credential to already exist).

Flagged, not done:

  • The legacy employee-documents table and any documents stored under the old mechanism were not backfilled into the new table - a one-off migration tool would be needed to move old files over without losing them, and that needs real validation before running against production data, same caution as #140's data-fix.
  • Storage is local-filesystem only for now, matching the platform's actual current state everywhere (Azure Blob support doesn't exist yet anywhere on the platform, including in EMR, the reference module) - a real production deployment needs that added to the shared kernel first, which is intentionally out of this ticket's scope (a shared-kernel change affects every module, not just HR).
  • Upload validation checks file type and size only, not deeper content signature sniffing - matches HR's prior validation depth, flagged as a possible future hardening.

Tests: HR backend unit 1315/1315 passed; HR backend integration 250/250 passed; HR frontend 105/105 files, 824/824 tests passed, type-check clean; Admin backend 4077/4077 passed. Includes a schema migration (new hr.documents table + employee photo FK) - ordinary, safe to run normally. Role re-seed needed for the renamed permission keys.

RH Updated by Roshni Harish. 3 days ago Actions #4

  • Assignee changed from Roshni Harish. to Sravan V S
Actions

Also available in: PDF Atom