Skip to content

fix(nextjs): Warn about missing encryption key while preserving keyless mode support - #4766

Merged
panteliselef merged 4 commits into
mainfrom
elef/actls-34-investigate-missing-clerk_encryption_key-warning-in
Dec 12, 2024
Merged

panteliselef merged 4 commits into
mainfrom
elef/actls-34-investigate-missing-clerk_encryption_key-warning-in

Conversation

@panteliselef

@panteliselef panteliselef commented Dec 12, 2024 •

Copy link
Copy Markdown
Contributor

Description

During rendering, both await currentUser() and await clerkClient() rely on the secret key being accessible, either through encrypted data or an environment variable. However, in Keyless mode, it is guaranteed that the secret key will not be available via an environment variable. Therefore, the secret key must be passed from the middleware to the rendering server.

Previously, we merged resolvedData (middleware options) with the pk and sk keys that exist in Keyless mode. In this PR, we ensure that the pk and sk keys from Keyless mode remain included in the encrypted data. Additionally, we refine the logic to correctly identify these keys, so the warning about a missing ENCRYPTION_KEY is shown only when a secret key is explicitly passed as an option to clerkMiddleware.

The bug was introduced in #4602

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-bot Bot commented Dec 12, 2024 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b413d2c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Patch

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

@vercel

vercel Bot commented Dec 12, 2024 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 2:15pm

Comment thread .changeset/cold-feet-develop.md Resolved
Comment thread packages/nextjs/src/server/utils.ts Resolved
Comment thread packages/nextjs/src/server/utils.ts Resolved

@LauraBeatris LauraBeatris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I've just left a couple of questions for clarification, no blockers tho

@panteliselef
panteliselef force-pushed the elef/actls-34-investigate-missing-clerk_encryption_key-warning-in branch from 87b368d to b413d2c Compare December 12, 2024 14:13
@panteliselef
panteliselef enabled auto-merge (squash) December 12, 2024 14:14
@panteliselef
panteliselef merged commit f86e836 into main Dec 12, 2024
@panteliselef
panteliselef deleted the elef/actls-34-investigate-missing-clerk_encryption_key-warning-in branch December 12, 2024 14:20
jakobevangelista pushed a commit that referenced this pull request Jan 9, 2025
wobsoriano pushed a commit that referenced this pull request Feb 8, 2025

This branch was successfully deployed

1 active deployment
Preview — b413d2c9 Deployed Dec 12, 2024 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants