Skip to content

feat: add IsProd components and encryption guardrail#5131

Merged
adrians5j merged 6 commits intonextfrom
adrian/encryption-in-wcfgtsx-2026-04-23
Apr 24, 2026
Merged

feat: add IsProd components and encryption guardrail#5131
adrians5j merged 6 commits intonextfrom
adrian/encryption-in-wcfgtsx-2026-04-23

Conversation

@adrians5j
Copy link
Copy Markdown
Member

@adrians5j adrians5j commented Apr 23, 2026

What changed

New project templates now include <Infra.Encryption> preconfigured for production environments, driven by the WEBINY_ENCRYPTION_PASSPHRASE environment 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.IsProd and Infra.Env.IsNotProd, make it easy to scope config to production (or non-production) environments without repeating environment name lists. Infra.ProductionEnvironments is mounted in the base template with prod and production as 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.IsProd and Infra.Env.IsNotProd read from a new ProductionEnvironmentsContext — a React state context injected by ProductionEnvironmentsCollector in renderConfigWorker.tsx. Infra.ProductionEnvironments gains a render function whose Registrar child calls useEffect to push its environments prop into the context on mount, triggering a re-render before the debounced onChange fires. The multiple: true flag was removed so a user-declared instance fully replaces the default.

ValidateEncryptionBeforeDeploy is a new BeforeDeploy hook registered in Project.tsx. It uses GetProductionEnvironments to check if the current env is production, then looks for an Infra/Encryption extension in the rendered project config via extensionsByType("Infra/Encryption"). If missing, it throws a GracefulError pointing to WEBINY_ENCRYPTION_PASSPHRASE and <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.IsProd and Infra.Env.IsNotProd — let you scope infrastructure config to production environments without repeating environment name lists everywhere.

Squash Merge Commit

feat: add IsProd components and encryption guardrail (#5131)

@adrians5j adrians5j added this to the 6.3.0 milestone Apr 23, 2026
@adrians5j adrians5j changed the title adrian/encryption-in-wcfgtsx-2026-04-23 feat: add IsProd components and encryption guardrail Apr 24, 2026
@adrians5j adrians5j merged commit 330cfef into next Apr 24, 2026
15 checks passed
@adrians5j adrians5j deleted the adrian/encryption-in-wcfgtsx-2026-04-23 branch April 24, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant