feat: sign og image urls by default#638
Merged
Merged
Conversation
Previously runtime OG image URLs were only signed when a `security.secret` was configured; without one the `/_og/d/**` endpoint accepted arbitrary unsigned requests. Now a per-build secret is auto-generated when none is set, so URL signing is on by default with no configuration. - Resolve the signing secret via a pure `resolveSigningSecret()`: explicit opt-out (`secret: false`) > explicit config/env value > auto-generated. - The auto value is random, server-only, and baked into the build. It is stable within a build artifact (runtime sign + verify agree) but rotates per build, so an explicit secret is still recommended for rolling/multi-instance deploys — surfaced via a dev warning, gated on having a server runtime (no warning for pure SSG/static builds). - Only an explicit secret is baked into the `ogImage.secret` override channel, keeping the `NUXT_OG_IMAGE_SECRET` runtime override (e.g. Cloudflare env) reachable. The auto value lives solely in the build-time `security.secret`. - `strict` still requires an explicit secret (the auto value's per-build rotation isn't a strong enough guarantee). - `security.secret: false` disables signing entirely. Test fixtures that assert unsigned dynamic URLs (basic, cloudflare-satori, vercel-edge-satori) opt out via `secret: false`; signing remains covered by the url-signing unit tests and the cloudflare-runtime-config e2e.
commit: |
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.
❓ Type of change
📚 Description
Runtime OG image URLs were only signed when a
security.secretwas set; without one the/_og/d/**endpoint accepted arbitrary unsigned requests. This makes signing the default by auto-generating a per-build secret when none is configured.How resolution works (
resolveSigningSecret, pure + unit-tested):security.secret: false→ signing disabled (explicit opt-out).The auto-generated secret is random, server-only, and baked into the build. It is stable within a build artifact (so runtime sign and verify agree) but rotates per build, which is fine for prerendered/cached images and single-instance deploys; rolling or multi-instance deploys want a stable secret so URLs signed by one build verify on another. A dev warning surfaces this, gated on actually having a server runtime so pure SSG/static builds stay quiet.
Two details worth calling out:
ogImage.secretoverride channel; the auto value lives solely in the build-timesecurity.secretfallback. This keeps theNUXT_OG_IMAGE_SECRETruntime override (e.g. Cloudflare env bindings) reachable.strictstill requires an explicit secret — the auto value's per-build rotation isn't a strong enough guarantee for strict mode.Runtime og:image URLs now include a signature by default, so:
/_og/d/...URLs will see a,s_…suffix./_og/d/requests against a production runtime are rejected with403.Prerendered (
/_og/s/) URLs are unaffected (never signed), and dev mode skips verification.📝 Migration
ogImage: { security: { secret: false } }.NUXT_OG_IMAGE_SECRET(orsecurity.secret). Generate one withnpx nuxt-og-image generate-secret.Fixtures that assert unsigned dynamic URLs (
basic,cloudflare-satori,vercel-edge-satori) opt out viasecret: false; signing stays covered by theurl-signingunit tests and thecloudflare-runtime-confige2e.