Skip to content

feat: apply organization seals after the last signature - #9553

Open
no84by wants to merge 3 commits into
LibreSign:mainfrom
no84by:feat/organization-seals
Open

no84by wants to merge 3 commits into
LibreSign:mainfrom
no84by:feat/organization-seals

Conversation

@no84by

@no84by no84by commented Nov 18, 2026 •

Copy link
Copy Markdown

Resolves: #9547
Part of #7236 (company seal next to personal signatures). Roadmap: #9443 (certificates by organizational context), #8946 (PAdES).

Depends on #9552 (no certification on an already signed document).

Summary

Adds organization seals: signatures applied by the organization after the last signer has signed.

  • An administrator configures one or more seal certificates (PKCS#12, each with a label) with occ libresign:organization-seal:add|list|delete. The PKCS#12 content and its password are stored in a sensitive (encrypted) app config value; the list only exposes id, label, subject and expiry.
  • A new request policy organization_seals (list of seal ids, default [], request snapshot) selects the seals. A requester chooses no seal, one or several with policy.overrides.organization_seals when the administrator allows request overrides; unknown ids are rejected (422) and the value cannot change once the request is sent.
  • When the request reaches SIGNED, each chosen seal is added with the configured signing engine (JSignPdf or native) as an extra signature without visible field. The document is already signed, so the engine adds an approval signature and never certifies it (this relies on fix: never certify a document that is already signed #9552). A document certified with "no changes allowed" is not sealed. A failing seal never fails the signer's signature; the outcome per seal is stored in the file metadata (organization_seals) and the file's signed hash is the sealed one.

Off by default: with no seal configured or chosen, behaviour is unchanged.

Question for maintainers

The validation view marks every certificate chain of a file whose hash matches LibreSign's signed hash as trusted (Pkcs12Handler::setIsLibreSignFile). A sealed file matches, so the seal certificate, issued by an external CA, is shown as "Certificate is trusted" whatever its real trust. This PR does not change the validation view: should seal signatures be shown with their own trust status (for example by marking only certificates issued by LibreSign's CA as LibreSign certificates)?

Not in this PR (follow-ups): admin settings UI and request UI for the seals; showing seal signatures as such in the validation view; retrying a failed seal; per-group restriction of which seals a requester may use.

How to test

  1. occ libresign:organization-seal:add "Main seal" /path/to/seal.p12 (password prompted, or --password-from-env with LIBRESIGN_SEAL_PASSWORD), then occ libresign:organization-seal:list.
  2. Create a request as admin with "policy": {"overrides": {"organization_seals": ["<id>"]}}.
  3. Sign as every signer. The signed PDF has one extra signature per seal, the file metadata has organization_seals.<id>.status = sealed, and with DocMDP enabled the document still has a single certification.

Validation evidence

  • Focused regression/acceptance test: unit tests for the store, policy, file policy applier, seal service, command and the sign hook; the engine behaviour on already signed documents is covered by the tests of fix: never certify a document that is already signed #9552.
  • Relevant lint/type/static-analysis checks: php-cs-fixer, psalm (no new issues), translator hints, composer openapi + npm run typescript:generate, OpenAPI tests.
  • Broader suite required by the changed surface
  • CI reviewed

API / Back-end changes

  • New policy organization_seals (backend only for now), new occ commands, seal step in SignFileService.
  • Unit and/or integration tests added or updated
  • Authorization and negative paths checked when applicable (override needs the existing policy delegation; unknown seal; frozen request; DocMDP level 1; failing seal)
  • Capabilities updated when applicable
  • Documentation updated when applicable
  • API documentation regenerated with composer openapi when necessary

Checklist

  • I have read and followed the contribution guide.
  • The diff does not contain unrelated refactors or generated changes.
  • Commits follow Conventional Commits where applicable.
  • All commits include the required DCO sign-off.

AI (if applicable)

  • The content of this PR was partially or fully generated using AI

A certification (DocMDP) signature has to be the first signature of
a document. With DocMDP enabled, the native engine certified every
invisible signature, also on a document that was already signed or
already certified, which invalidates the earlier signatures' DocMDP
semantics. Certify only when the document has no signature yet, for
invisible and visible signatures alike.

Signed-off-by: no84by <50858621+no84by@users.noreply.github.com>
…nature

The JSignPdf parameters are kept on the handler between signatures and
new parameters are merged into them. After a certifying signature, the
next signature made by the same handler (for example on a document that
is already signed) still carried "-cl" and certified again. When DocMDP
is enabled, a signature that does not certify now sends
"-cl NOT_CERTIFIED", which replaces any earlier level.

Signed-off-by: no84by <50858621+no84by@users.noreply.github.com>
An administrator can configure organization seal certificates
(PKCS#12, each with a label) with the new
libresign:organization-seal:add|list|delete commands. The PKCS#12
content and its password are kept in a sensitive app config value.

The new organization_seals policy holds the list of seals applied to
a request. It defaults to no seal and is stored on the request like
the other request policies, so a requester picks no seal, one seal or
several through policy.overrides when the administrator allows it.

When the last signer signs, every chosen seal is added with the
configured signing engine as an extra signature without visible
field. The document is already signed, so the engine adds an approval
signature and never certifies it. A document certified with no
changes allowed is not sealed. A seal that cannot be applied never
fails the signature; the result of every seal is stored in the file
metadata under organization_seals.

Signed-off-by: no84by <50858621+no84by@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Organization seals after the last signature

1 participant