Skip to content

[WHIT-3020] Allow publishers to delete a document preview link#11543

Open
TonyGDS wants to merge 5 commits into
whit-3020-backfill-cfe-auth-bypassfrom
whit-3020-deletable-preview-tokens
Open

[WHIT-3020] Allow publishers to delete a document preview link#11543
TonyGDS wants to merge 5 commits into
whit-3020-backfill-cfe-auth-bypassfrom
whit-3020-deletable-preview-tokens

Conversation

@TonyGDS

@TonyGDS TonyGDS commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Part 2 of 3 for WHIT-3020 (opt-in preview tokens). Stacked on #11555. Adds the ability for publishers to delete a document's shareable preview token. Token auto-generation is unchanged here — it flips to opt-in in PR #11542.

Jira

How

  1. Make absent auth_bypass_ids serialise to an empty array.compact the auth_bypass_ids in the Publishing API presenters and in the attachment, image and response-form data models, so a token-less edition serialises to [] rather than [nil].
  2. Allow editions.auth_bypass_id to be null — migration allowing a token to be removed.
  3. Add EditionAuthBypassRevoker service — nils the token, republishes the draft, and sends auth_bypass_ids: [] to Asset Manager for attached files and images. AddEditionAuthBypassAssetPropagator for shared logic reused by the existing updater.
  4. Allow publishers to delete a document preview link — Add destroy_bypass_id action + DELETE route, requiring :update on the edition.
  5. Give the share preview section explicit token states — two-state "Share preview link with someone else" section: token present → copy link + "Generate new link" + "Delete link"; no token → "Generate link" only.

Behaviour

Every draft still auto-gets a token (removed in #11542), so the preview section shows the token-present state. Deleting a token reaches the empty state. Regenerating or deleting removes the previous token from Whitehall, Publishing API and Asset Manager, so the old link returns 403 for unauthorised users.

Screenshots

Before — single-state section

Screenshot 2026-06-10 at 11 50 35

After — no token (empty state)

Screenshot 2026-06-09 at 16 23 36

After — token present

Screenshot 2026-06-09 at 16 23 52

Testing

Next

PR #11542: Make preview token generation opt-in (removes the auto-generation callback).

@TonyGDS TonyGDS force-pushed the whit-3020-deletable-preview-tokens branch 6 times, most recently from 9163764 to f642e3e Compare June 10, 2026 10:18
@TonyGDS TonyGDS changed the title [WHIT-3020] Allow publishers to delete or regenerate a document preview link [WHIT-3020] Allow publishers to delete a document preview link Jun 10, 2026
@TonyGDS TonyGDS force-pushed the whit-3020-deletable-preview-tokens branch from f642e3e to d35f18e Compare June 10, 2026 10:42
@TonyGDS TonyGDS marked this pull request as ready for review June 10, 2026 12:01
@TonyGDS TonyGDS force-pushed the whit-3020-deletable-preview-tokens branch 3 times, most recently from 92202fe to 381379d Compare June 12, 2026 13:34
@TonyGDS TonyGDS changed the base branch from main to whit-3020-backfill-cfe-auth-bypass June 12, 2026 13:34
@TonyGDS TonyGDS force-pushed the whit-3020-backfill-cfe-auth-bypass branch from aa6603c to c6d23b1 Compare June 12, 2026 13:38
@TonyGDS TonyGDS force-pushed the whit-3020-deletable-preview-tokens branch from 381379d to b25327c Compare June 12, 2026 13:38
@TonyGDS TonyGDS force-pushed the whit-3020-backfill-cfe-auth-bypass branch from c6d23b1 to ce3d9c1 Compare June 12, 2026 15:08
@TonyGDS TonyGDS force-pushed the whit-3020-deletable-preview-tokens branch from b25327c to 729c9eb Compare June 12, 2026 15:08
@TonyGDS TonyGDS force-pushed the whit-3020-backfill-cfe-auth-bypass branch from ce3d9c1 to 4ccffe7 Compare June 12, 2026 15:18
@TonyGDS TonyGDS force-pushed the whit-3020-deletable-preview-tokens branch from 729c9eb to 30f8365 Compare June 12, 2026 15:18
TonyGDS added 5 commits June 12, 2026 16:48
Compact the auth_bypass_ids arrays in the Publishing API presenters and
in the attachment, image and response-form data models, so an edition
without a token serialises to [] rather than [nil]. This is the
foundation for letting publishers delete a preview token and for making
token generation opt-in.
Drop the NOT NULL constraint on editions.auth_bypass_id so that a token
can be removed from a draft. Deleting a token sets the column to nil,
which the previous constraint rejected.
Add a service that removes a draft's auth bypass token: it nils the
edition's auth_bypass_id, saves the edition, republishes via the updater
and sends auth_bypass_ids: [] to Asset Manager for every attached file
and image.

Extract the shared Asset Manager propagation into
EditionAuthBypassAssetPropagator, which derives the value from the
edition's current auth_bypass_id, and reuse it from
EditionAuthBypassUpdater.
Add a destroy_bypass_id action and DELETE route that removes a draft's
auth bypass token via EditionAuthBypassRevoker. Like update_bypass_id it
loads the edition and requires :update permission on it.
Render the "Share preview link with someone else" section in two states:
when a token exists, show the copy link with options to regenerate or
delete it; when no token exists, show only a button to generate one.
Deleting a token flips the summary page to the empty state.
@TonyGDS TonyGDS force-pushed the whit-3020-backfill-cfe-auth-bypass branch from 4ccffe7 to 51b99f2 Compare June 12, 2026 15:48
@TonyGDS TonyGDS force-pushed the whit-3020-deletable-preview-tokens branch from 30f8365 to 192753b Compare June 12, 2026 15:48
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.

1 participant