feat: add IsProd components and encryption guardrail#5131
Merged
Conversation
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.
What changed
New project templates now include
<Infra.Encryption>preconfigured for production environments, driven by theWEBINY_ENCRYPTION_PASSPHRASEenvironment variable. Additionally, deploying to a production environment without encryption configured now fails with a clear, actionable error rather than silently succeeding.Two new components,
Infra.Env.IsProdandInfra.Env.IsNotProd, make it easy to scope config to production (or non-production) environments without repeating environment name lists.Infra.ProductionEnvironmentsis mounted in the base template withprodandproductionas defaults; users can override by declaring their own instance.Why
Encryption was easy to forget when setting up a production environment — there was no scaffolded reminder in the project template and no guardrail at deploy time. Users could deploy to production without encryption, which is a security gap. The
Infra.Env.Is env="prod"pattern also forced users with multiple production environments (e.g.prod-eu,prod-us) to repeat the full env list at every usage site.How
Infra.Env.IsProdandInfra.Env.IsNotProdread from a newProductionEnvironmentsContext— a React state context injected byProductionEnvironmentsCollectorinrenderConfigWorker.tsx.Infra.ProductionEnvironmentsgains arenderfunction whoseRegistrarchild callsuseEffectto push itsenvironmentsprop into the context on mount, triggering a re-render before the debouncedonChangefires. Themultiple: trueflag was removed so a user-declared instance fully replaces the default.ValidateEncryptionBeforeDeployis a newBeforeDeployhook registered inProject.tsx. It usesGetProductionEnvironmentsto check if the current env is production, then looks for anInfra/Encryptionextension in the rendered project config viaextensionsByType("Infra/Encryption"). If missing, it throws aGracefulErrorpointing toWEBINY_ENCRYPTION_PASSPHRASEand<Infra.Encryption>.Changelog
Added Production Environment Helpers and Encryption Guardrail
New project templates now include encryption preconfigured for production environments, and deploying to production without encryption set will fail with a clear error message. Two new components —
Infra.Env.IsProdandInfra.Env.IsNotProd— let you scope infrastructure config to production environments without repeating environment name lists everywhere.Squash Merge Commit