Skip to content

Serve the EAJE attestation proof via the X-Generate-Proof header - #296

Open
Un3x wants to merge 6 commits into
developfrom
feature/api-6792-ajout-dun-pdf-signe
Open

Serve the EAJE attestation proof via the X-Generate-Proof header#296
Un3x wants to merge 6 commits into
developfrom
feature/api-6792-ajout-dun-pdf-signe

Conversation

@Un3x

@Un3x Un3x commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Replace the dedicated attestation endpoint with the X-Generate-Proof: proof-only|pdf header on the EAJE identite call: proof link + visual code in meta, short-lived self-contained PDF link in links — one provider call, no extra scope.

  • Verification page moves to site/ at /attestations/verification/:token (native DSFR, Rails-native rate limit, tracker-free layout), decrypting with a dedicated attestation_encryptor_* key shared by both apps
  • Unauthenticated /api/attestations/:token.pdf renders the PDF from its self-contained token — 410 stale, 404 forged; footer QR is now also a clickable link
  • SDKs regenerated: dedicated resource dropped, header exposed as generate_proof: in both clients (scaffolds now emit in: header params)

Closes API-6792 → https://linear.app/pole-api/issue/API-6792/ajout-dun-pdf-signe

Avant de deploy il faut merge : https://github.com/etalab/very_ansible/pull/828 et apply

@linear

linear Bot commented Jul 23, 2026

Copy link
Copy Markdown

API-6792

@Un3x
Un3x force-pushed the feature/api-6792-ajout-dun-pdf-signe branch 3 times, most recently from 2212cb8 to 68df22d Compare July 24, 2026 13:59
@Un3x

Un3x commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Itération 3 : rendu PDF conforme à la maquette (retour de test sandbox du 27/07, détail sur API-6792).

@Un3x

Un3x commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Historique replié pour la review : les 8 commits itératifs d'hier tiennent en 2 (arbre final inchangé, diff strictement identique).

@Un3x
Un3x requested review from Samuelfaure and skelz0r July 28, 2026 06:40
@Un3x

Un3x commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Il y a probablement des choses à redire, c'est néanmonis testé et validé en fonctionnement en sandbox.

L'app y est déployé actuellement, vous pouvez faire des requêtes curl récup l'attestation et scanner le QR code pour récup la vérification.

A priori, besoin d'aucune modification en staging ni de fake data on génère un vrai pdf sur de la fausse données et c'est ok, facile à tracé parce que ca ne répond à nos mocks qui sont tracable.

@skelz0r

skelz0r commented Jul 28, 2026

Copy link
Copy Markdown
Member

Est-ce que tu peux upload un pdf directement ici, ainsi que le curl ?

@skelz0r

skelz0r commented Jul 28, 2026

Copy link
Copy Markdown
Member

La description fonctionnelle de cette PR est incompréhensible, peux-tu clarifier ?

@skelz0r skelz0r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai plusieurs gros points:

  1. C'est beaucoup trop couplé entre le type de données et le pdf (2 coms) tout en étant très générique ;
  2. La spec a complètement divergé (ajout d'un header qui permet d'avoir un lien de vérif et/ou un pdf, dans la même réponse sans ajouter de nouvel endpoint) : pourquoi ? Le design me semble plus pauvre que la spec initiale, d'autant plus qu'on complexifie pas mal de choses en procédant de cette manière. Le but n'est pas de produire un nouveau type de réponse mais de la preuve, je trouve ça très étrange de l'exposer dans un endpoint de données (à la limite via une extension aurait été plus logique mais bon..)
  3. Les commits messages sont cryptiques, cela devrait être autoportant

Le 2. m'a excessivement brainfuck, pourquoi ? Cela devrait être dans le commentaire initial de la PR.

Comment thread siade/app/controllers/api_particulier/attestations_verification_controller.rb Outdated
Comment thread siade/app/services/attestation_token.rb Outdated
Comment thread siade/app/services/attestation_token.rb Outdated
Comment thread siade/app/services/attestation_token.rb Outdated
Comment thread siade/app/services/attestation_pdf.rb
Comment thread commons/data/authorizations.yml Outdated
@skelz0r

skelz0r commented Jul 28, 2026

Copy link
Copy Markdown
Member

Btw j'ai lu commit / commit, et je me suis arrêté quand j'ai constaté le point 2.

@Un3x

Un3x commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Est-ce que tu peux upload un pdf directement ici, ainsi que le curl ?

pour le moment je n'ai testé que en sandbox avec des données réelles donc non, mais je peux générer un fake en local pour illustrer

@Un3x Un3x changed the title Add verifiable PDF attestation for participation familiale EAJE Serve the EAJE attestation proof via the X-Generate-Proof header Jul 29, 2026
@Un3x

Un3x commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Deploy prerequisite: provision attestation_encryptor_password/attestation_encryptor_salt (same pair per env) in siade and site credentials before staging/prod — details on the Linear issue.

@Un3x
Un3x force-pushed the feature/api-6792-ajout-dun-pdf-signe branch from ca5f327 to ec56f71 Compare July 29, 2026 13:06
Un3x added 5 commits July 29, 2026 17:26
Two purposes on one dedicated key pair (attestation_encryptor_*)
provisioned in both siade and the site app: a 5-year verification
token holding the RSSI §4.4 minimum — allocataires truncated,
children reduced to a count so the payload stays QR-sized whatever
the family — and a 5-minute PDF-link token carrying the full payload,
whose in-payload expiry distinguishes a stale link (410) from a
forged one (404). Sharing a dedicated key rather than the
general-purpose encryptor lets the web app verify documents without
calling siade and without widening the blast radius of the existing
secret; that encryptor now memoizes its derived key (PBKDF2 ran on
every INPI link before).
DSFR-styled document (hexapdf): label/value grid with French labels,
Marianne header, keep-together sections, test-data banner, and a
footer carrying the vector QR code, the visual code and the
provenance line (SIRET + habilitation, RSSI traceability). The
footer is also a link annotation to the same verification URL with
the domain spelled out, so digital readers can click instead of
scanning their own screen. Field labels load from
commons/data/attestation_eaje_labels.yml, shared with the site app's
verification page: a fraud check compares these exact strings across
the two documents, so they must not drift.
X-Generate-Proof on the standard identite call replaces the idea of a
dedicated attestation endpoint: proof-only enriches meta with the
verification link and visual code, pdf adds a short-lived
unauthenticated download link in links — one provider call serves the
data and its proof, no extra scope, data block unchanged. The link is
honored on mocked responses too (staging is where FQF integrators
test), which required treating empty identity params like absent ones
when matching mock payloads. Following the link hits a bare public
controller that decrypts the self-contained token and renders the
PDF — re-downloadable until expiry, 410 once stale, 404 when forged —
throttled per IP alongside the verification page. The endpoint sheet
and OpenAPI spec document the header.
The page lives where humans and DSFR live: site serves it at the
clean /attestations/verification/:token URL the QR encodes — no /api
prefix, no nginx exception — with the design system, the Rails-native
rate limit, no-store/noindex and a tracker-free dedicated layout
(RSSI: no cookies, no external resource). The shared attestation key
lets site decrypt tokens on its own, so verification works even with
siade down; a valid token shows the truncated subset and the visual
code, anything else is a data-free 404.
Response envelopes now hand meta and links through on every call and
tolerate binary bodies (a followed attestation link returns raw PDF
bytes), and both scaffolds emit in:header OpenAPI parameters as
optional kwargs wired to real request headers — X-Generate-Proof
becomes generate_proof: on the EAJE identite method. Cache-Control
stays unscaffolded as transport-level. SPECS.md makes both rules
normative for future language ports; minor release for each package
after merge.
@Un3x
Un3x force-pushed the feature/api-6792-ajout-dun-pdf-signe branch from ec56f71 to 5d6f180 Compare July 29, 2026 15:27
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.

2 participants