Add blockFilesWithExpiredLicense option to DamConfig - #6315
Draft
VPS-thodax wants to merge 1 commit into
Draft
Conversation
The license duration of a DAM file was purely informational: expired licenses were surfaced as warnings in the Admin, but the public DAM routes kept delivering the file, so a site could keep showing an image whose rights had run out. Add the opt-in `blockFilesWithExpiredLicense` option to `DamConfig`, which makes the public image and file routes respond with a 404 for files whose license has expired. Cap the cache lifetime of files with a license end date at the expiration date when the option is enabled, because browsers and CDNs would otherwise keep serving them for up to a year. Move the license validity checks out of `FileLicensesResolver` into `license.util.ts` so the resolver and the controllers share one implementation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L22ETjLL8qy8xS2gcKZUmz
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The license duration of a DAM file is purely informational. An expired license is surfaced as a
fileLicenseExpiredwarning in the Admin and ashasExpiredon the GraphQL API, but the public DAM routes never look at it — they only validate the URL hash and the content hash. A site therefore keeps delivering an image whose rights have run out, and nothing but an editor noticing the warning stops it.Solution
DamConfiggets an opt-inblockFilesWithExpiredLicenseoption. When it is enabled (together withenableLicenseFeature), the public image and file routes respond with a 404 for files whose license has expired. It defaults tofalse, so delivery is unchanged for existing projects.The public routes cache aggressively (
max-age=31536000, s-maxage=86400), so blocking alone would be ineffective: browsers and CDNs would keep serving a file long after its license expired. When the option is enabled, the cache lifetime of files with a license end date is therefore capped at the expiration date.The license validity checks move from
FileLicensesResolverintolicense.util.tsso the resolver and the controllers share one implementation. The GraphQL schema is unchanged.Decisions
isValidon the API also coversdurationFrombeing in the future, but a license bought in advance is a normal editorial state and blocking it would surprise. If not-yet-valid files should be blocked too, that's a follow-up.Verification
license.util.spec.tscovers the expiry boundary (a license is valid through itsdurationToday and expires one day later), the config gating (neither flag alone blocks anything), files without a license or without an end date, and the cache header in all four cases: uncapped, cappedmax-ageonly, both capped, and0for an already-expired license.Verified that
demo/apistill boots itsAppModuleand regeneratesschema.gql/block-meta.jsonwithout changes (it then fails on the missing local database, which is expected in this environment).Further information
🤖 Generated with Claude Code
https://claude.ai/code/session_01L22ETjLL8qy8xS2gcKZUmz
Generated by Claude Code