Skip to content

Sign and encrypt template accounts with app keys - #240

Merged
tnkuehne merged 1 commit into
feat/builder-patchesfrom
feat/templates-without-auth-secret
Nov 20, 2026
Merged

tnkuehne merged 1 commit into
feat/builder-patchesfrom
feat/templates-without-auth-secret

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What changes

  • Better Auth keys option (in the existing better-auth and @better-auth/core 1.7.12 patches): with keys: { sign, verify, encrypt, decrypt }, Better Auth signs the state and session cookies and encrypts saved OAuth tokens through these operations instead of secret. Without the option nothing changes, so the control plane is unaffected. With the option and no secret, features that still use a secret get a value that changes per instance, so they fail instead of falling back to Better Auth's well-known default.
  • Templates (Gmail, GitHub, OneDrive) pass WIDEFLEET_KEYS ("cookies" and "tokens" keys) as keys. AUTH_SECRET is gone from the code, the setup page and template.md.
  • Standalone installs: each template declares the patches in its own pnpm-workspace.yaml and carries copies of the root patch files. pnpm and the app builder (previous PR) apply them. apps/control-plane/tests/template-patches.test.ts keeps the copies identical to the root patches.
  • docs/development.md explains the keys option and that a template directory is now its own pnpm workspace: run template commands from the repository root.

Verification

  • Template tests (42) pass. The test worker stands in for WIDEFLEET_KEYS, and saved tokens are encrypted through it.
  • Control-plane auth tests (67) pass with the patched Better Auth.
  • The app builder bundled and documented the GitHub template against the public npm registry with the patches applied.

Deployment order

Template installs read templates from main. Installations need the runtime with WIDEFLEET_KEYS (first PR in this stack) before they install templates from this change.

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

The PR appears safe to merge, with no new actionable defect found.

Summary

Moves Gmail, GitHub and OneDrive cookie signing and saved-token encryption to WIDEFLEET_KEYS.

  • Connector templates use Widefleet keys for Better Auth cookies and saved OAuth tokens.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Templates["Gmail / GitHub / OneDrive"] --> Auth["Better Auth"]
  Auth -->|sign and verify cookies| Keys["`WIDEFLEET_KEYS`"]
  Auth -->|encrypt and decrypt tokens| Keys
  Keys --> Runtime["Keys kept by the app runtime"]
  Auth --> Cookies["Signed cookies"]
  Auth --> Accounts["Encrypted saved tokens"]
Loading

Reviews (8) · Last reviewed commit: "Sign and encrypt template accounts with ..." · Reviewed by Greptile

@tnkuehne
tnkuehne added this pull request to stack #239 November 20, 2026 11:19
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 802a0ed Nov 20 2026, 01:54 PM

Comment thread templates/gmail/src/auth.ts Resolved
Comment thread templates/github/template.md Resolved
@tnkuehne
tnkuehne force-pushed the feat/templates-without-auth-secret branch from 4dc6d50 to f9b1c8a Compare November 20, 2026 11:38
@tnkuehne
tnkuehne force-pushed the feat/templates-without-auth-secret branch 3 times, most recently from 21f384c to 1cc5caf Compare November 20, 2026 12:08
@tnkuehne
tnkuehne force-pushed the feat/templates-without-auth-secret branch from 1cc5caf to 42b4473 Compare November 20, 2026 12:36
@tnkuehne
tnkuehne force-pushed the feat/templates-without-auth-secret branch from 42b4473 to 810b65f Compare November 20, 2026 12:56
The connector templates no longer need AUTH_SECRET. Better Auth gains a keys
option through the existing patches, and the templates use it to sign cookies
and encrypt saved account tokens with WIDEFLEET_KEYS, so app code never holds
key material. Each template ships the patches in its own pnpm-workspace.yaml
for standalone installs and server builds.
@tnkuehne
tnkuehne force-pushed the feat/templates-without-auth-secret branch from 810b65f to 802a0ed Compare November 20, 2026 13:53
@tnkuehne
tnkuehne merged commit f951f5f into main Nov 20, 2026
17 checks passed
@tnkuehne
tnkuehne deleted the feat/templates-without-auth-secret branch November 20, 2026 14:43
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