-
Notifications
You must be signed in to change notification settings - Fork 87
feat(security): HMAC signing infrastructure for proxy endpoints #699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e8434f1
feat(security): HMAC signing infrastructure for proxy endpoints
harlan-zw 6724959
chore: remove em dashes from comments and strings
harlan-zw d13999a
refactor(security): replace /sign endpoint with stateless page tokens
harlan-zw c3a6997
feat(security): wire withSigning on all proxy/embed handlers
harlan-zw deacf59
fix(security): pass through when no proxy secret is configured
harlan-zw 2b6605d
fix(security): defer secret resolution and downgrade prod error to waβ¦
harlan-zw eee5ffc
fix: lazy-resolve useRuntimeConfig in withSigning
harlan-zw 48c0865
test: add resolveProxySecret and verifyProxyRequest tests
harlan-zw 4e234d1
docs: add proxy endpoint security section to first-party guide
harlan-zw 695a48b
fix: remove unused existsSync import in test
harlan-zw be02643
docs(security): add signed endpoints table, config reference, and troβ¦
harlan-zw de1ecb4
docs(security): add signing callout to each registry script with proxβ¦
harlan-zw ed8d658
Merge branch 'main' into feat/proxy-url-signing
harlan-zw 51d3c14
fix(security): skip signing setup for SSG and SPA modes
harlan-zw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #!/usr/bin/env node | ||
| import('../dist/cli.mjs') |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,11 @@ | |
| ] | ||
| } | ||
| }, | ||
| "bin": { | ||
| "nuxt-scripts": "./bin/cli.mjs" | ||
| }, | ||
| "files": [ | ||
| "bin", | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /** | ||
| * @nuxt/scripts CLI. | ||
| * | ||
| * Currently hosts a single command, `generate-secret`, which produces a | ||
| * cryptographically random HMAC secret for `NUXT_SCRIPTS_PROXY_SECRET`. This | ||
| * is an alternative to letting the module auto-write a secret into `.env`, | ||
| * for users who want explicit control (e.g. teams that commit secrets to a | ||
| * vault rather than `.env`). | ||
| * | ||
| * Keep this file zero-dependency: it runs standalone via `npx @nuxt/scripts` | ||
| * and should boot instantly. | ||
| */ | ||
|
|
||
| import { randomBytes } from 'node:crypto' | ||
| import process from 'node:process' | ||
|
|
||
| function generateSecret(): void { | ||
| const secret = randomBytes(32).toString('hex') | ||
| process.stdout.write( | ||
| [ | ||
| '', | ||
| ' @nuxt/scripts: proxy signing secret', | ||
| '', | ||
| ` Secret: ${secret}`, | ||
| '', | ||
| ' Add this to your environment:', | ||
| ` NUXT_SCRIPTS_PROXY_SECRET=${secret}`, | ||
| '', | ||
| ' The secret is automatically picked up by the module via runtime config.', | ||
| ' It must be the same across all deployments and prerender builds so that', | ||
| ' signed URLs remain valid.', | ||
| '', | ||
| '', | ||
| ].join('\n'), | ||
| ) | ||
| } | ||
|
|
||
| function showHelp(): void { | ||
| process.stdout.write( | ||
| [ | ||
| '', | ||
| ' @nuxt/scripts CLI', | ||
| '', | ||
| ' Usage: npx @nuxt/scripts <command>', | ||
| '', | ||
| ' Commands:', | ||
| ' generate-secret Generate a signing secret for proxy URL tamper protection', | ||
| ' help Show this help', | ||
| '', | ||
| '', | ||
| ].join('\n'), | ||
| ) | ||
| } | ||
|
|
||
| const command = process.argv[2] | ||
|
|
||
| if (!command || command === 'help' || command === '--help' || command === '-h') { | ||
| showHelp() | ||
| } | ||
| else if (command === 'generate-secret') { | ||
| generateSecret() | ||
| } | ||
| else { | ||
| process.stderr.write(`Unknown command: ${command}\n`) | ||
| showHelp() | ||
| process.exit(1) | ||
| } |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.