Skip to content

Allow configuring a dedicated OCR user - #388

Open
R0Wi wants to merge 1 commit into
masterfrom
claude/workflow-ocr-user-setting-5tbsw5
Open

Allow configuring a dedicated OCR user#388
R0Wi wants to merge 1 commit into
masterfrom
claude/workflow-ocr-user-setting-5tbsw5

Conversation

@R0Wi

@R0Wi R0Wi commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Automated OCR operations are attributed to the impersonated file owner (audit-trail / accountability concern) #385: automated OCR operations were always attributed to the impersonated file owner, making them indistinguishable from manual edits in the version history and activity log.
  • Adds an optional global admin setting ("OCR user"). If left empty (default), behavior is unchanged and the file owner is impersonated as before. If set, the whole OCR run (user session, filesystem access, resulting file version/label) runs as that configured user instead.
  • Success notifications are still always sent to the file owner. If the configured user doesn't exist, the app logs a warning and falls back to the file owner.

Changes

  • lib/Model/GlobalSettings.php: new nullable processingUserId setting.
  • lib/Service/OcrService.php: reads global settings before initializing the user environment, determines the processing uid (configured user, or file owner as fallback), and separates the "processing user" from the "owner" (used for notifications).
  • lib/Service/GlobalSettingsService.php: empty string now maps to null for nullable string settings, mirroring the existing 0 -> null behavior for ints.
  • lib/Controller/GlobalSettingsController.php: trims and normalizes blank input to null.
  • src/components/GlobalSettings.vue: new text input for the OCR user, saved on blur.
  • README.md: documents the new setting and its permission requirements.

Test plan

  • Added OcrServiceTest::testRunsOcrProcessWithConfiguredProcessingUser and testFallsBackToFileOwnerIfConfiguredProcessingUserDoesNotExist.
  • Updated GlobalSettingsServiceTest and GlobalSettingsControllerTest for the new setting (including null/blank handling).
  • Added Vue tests for the new input in GlobalSettings.spec.js.
  • Ran full PHPUnit suite against a real Nextcloud (master) checkout — all workflow_ocr tests pass except 4 pre-existing/environmental failures unrelated to this change (missing Imagick extension, running as root).
  • Ran npm run test:unit (53 passed), npm run lint, and composer cs:check — all clean, no new issues introduced.

Generated by Claude Code

Automated OCR operations were always attributed to the owner of the
processed file, because the app impersonates that user to get proper
filesystem permissions. This makes automated OCR indistinguishable from
a manual user edit in the file version history and the activity log.

Add an optional global setting "OCR user". If it is set, the whole OCR
processing (user session, filesystem and therefore the resulting file
version) runs with that account instead of the file owner. If it is not
set, nothing changes and the file owner is impersonated as before.

Notifications are still sent to the file owner, and if the configured
user does not exist the app logs a warning and falls back to the owner.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PjP5Wsw6uiKSBPiXp9N7sf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automated OCR operations are attributed to the impersonated file owner (audit-trail / accountability concern)

2 participants