-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Allow passing into the crypto key via ASTRO_KEY #11879
Conversation
🦋 Changeset detectedLatest commit: c7c8cd8 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
!preview crypto-env |
Snapshots have been released for the following packages:
Publish Log
Build Log
|
I've tested this at least five times by generating an AES-256 key and adding this to package.json: "build": ASTRO_KEY=MY_KEY astro build The application was then built with, npm run build and deployed to a kubernetes cluster. I did not see any of the errors I've seen before during deploys, so this should fix the issue I had with rolling updates. Thank you for fixing this so quickly. |
Thanks @sasoria, I still need to write a test so this probably won't go out today. |
if(!hasKey && opts.settings.config.experimental.serverIslands) { | ||
this.logger.info('build', `This build generated a key to encrypt props passed to Server islands. To reuse the same key across builds, set this value as ASTRO_KEY in an environment variable on your build server. | ||
|
||
ASTRO_KEY=${await encodeKey(await keyPromise)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to print this? I'd be worried it would show in public logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah good point. Hm, I'm not sure what to do then. The only other way I can think to do this is with a new command. Something like astro generate-key
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably a better way to go. Will update the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New output is like:
Generated a key to encrypt props passed to Server islands. To reuse the same key across builds, set this value as ASTRO_KEY in an environment variable on your build server.
ASTRO_KEY=P90X3r0+nEqzystDC1pg01VS4s/+jINyDTYSNlEO0HQ=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. Not a blocker, but I wonder if it would make sense to write it to the user's .env
if there isn't already one set.
Changes
This makes it possible to pass in the cryptography used via the ASTRO_KEY environment variable.
This allows you to reuse the key in each build, ensuring that if you have separate server and client deployments that the keys are never out of sync.
Fixes Astro Islands fails with rolling update #11851
Keys are generated using
astro create-key
command.Testing
Docs
N/A