Merge conflict
Gerrit cannot merge this change. It needs a rebase onto main.
98317[TASK] Sign and verify preview tokens
Commit message
This patch adds an internal API: `PreviewTokenService` issues and verifies short-lived preview tokens. The class is marked @internal. No code in the core uses it yet. Later patches of #110664 use it: - "Check where a request with a preview token comes from" reads the backend session of the verified token and checks that the session is still active. - "Accept preview tokens in the frontend" calls `verify()` in the frontend middleware and reads the token from the query parameter `PreviewTokenService::PARAMETER`. - "Issue preview tokens in the backend" calls `issue()` when a backend user opens a preview and adds the token to the URI with the query parameter `PreviewTokenService::PARAMETER`. The backend must give the browser a short-lived proof that a backend user opened a preview. A site on another domain must check this proof without a shared session, because the backend session cookie does not reach it. The service signs a JWT with a key that it derives from the encryption key of the installation. `verify()` denies a token in these cases: - The token is malformed, or its signature is not valid. - One of its claims does not fit (`PreviewTokenClaims`). - The backend clock is more than 60 seconds ahead of the site clock. - The token expired more than 60 seconds ago. The lifetime is 15 minutes. - The browser is not the browser for which the backend issued the token. The token contains a hash of the user agent. The token also contains the backend session id. The site uses it to revoke the token when the backend session ends. The backend session id is the secret of the backend session cookie, and everybody who sees the URI can read the claims. Thus the service encrypts the id with `CipherService`. The backend user id is the additional data of the cipher. Thus the cipher is valid only for this backend user. The JWT library reads its clock and its leeway from public static properties that any code can set. The service sets its own clock and leeway for each check and restores the old values after the check. An expired token stays in the exception when its signature and its claims are valid. The later patch "Renew the preview token of the frame" uses the backend origin of this token to ask the backend for a fresh token. `PreviewDenialReason` gets the reasons "expired" and "otherBrowser". This patch needs "Add typed claims for preview tokens": `issue()` and `verify()` use `PreviewSimulation` and `PreviewToken`, and `verify()` checks the claims with `PreviewTokenClaims`. Merge that patch first, then this patch.
Show more Show less
Resolves: #TBD Related: #110664 Releases: main, 14.3 Change-Id: Ie5d5112e823f4cea0853cba377afbc3f17272041
Test this change
Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch
- Check out patch set 1
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/17/98317/1 && git checkout FETCH_HEAD
- Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/17/98317/1 && git cherry-pick FETCH_HEAD
Review
-
Code review CR 0 Needs a vote
-
Verified V -1 Blocked
- core-ci -1 CI
Relation chain 16
- 98329[BUGFIX] Use preview tokens in the frames of the workspace preview
- 98328[TASK] Add a live view kind of preview token
- 98327[BUGFIX] Follow the page of the preview frame in the backend
- 98326[BUGFIX] Keep the preview token in navigations that scripts start
- 98325[BUGFIX] Keep the preview token in links, forms and redirects
- 98324[BUGFIX] Renew the preview token of the frame
- 98323[TASK] Add one frame component for the preview frames of the backend
- 97235[BUGFIX] Preview hidden pages across site domains
- 98322[TASK] Accept preview tokens in the frontend
- 98321[TASK] Issue preview tokens in the backend
- 98320[TASK] Check where a request with a preview token comes from
- 98319[BUGFIX] Handle query parameters of links in one place
- 98318[TASK] Resolve the sites and hosts a backend user may preview
-
98317 [TASK] Sign and verify preview tokens This change
- 98316[TASK] Add typed claims for preview tokens
-
98315[TASK] Add a read-only backend user for one workspace
The chain has patch set 1 of 2, the changes above it need a rebase.
Issues 1
Files 3
Review log 23
-
Matthias Vogel uploaded patch set 1 12/04/26, 09:02
-
core-ci voted on patch set 1 V -1 12/04/26, 09:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116301
-
Matthias Vogel wrote 12/04/26, 10:25
Topic set to cross-domain-preview