Skip to content

Add JWT authentication for Tiptap collaboration on proposals#606

Draft
valentin0h wants to merge 9 commits intodevfrom
proposal-auth-tiptap
Draft

Add JWT authentication for Tiptap collaboration on proposals#606
valentin0h wants to merge 9 commits intodevfrom
proposal-auth-tiptap

Conversation

@valentin0h
Copy link
Collaborator

@valentin0h valentin0h commented Feb 15, 2026

Summary

Replaces the hardcoded notoken placeholder in the Tiptap collaboration provider with proper JWT authentication, so collaborative editing is actually secured per-user and per-document.

  • Users must have UPDATE permission on a proposal to receive a collaboration token, preventing unauthorized document edits through the Tiptap WebSocket connection
  • Tokens are scoped to a single document ID so a compromised or leaked token cannot access other proposals
  • Tokens refresh proactively and recover from expiry so long editing sessions do not silently lose sync

Users can only access collaboration documents for proposals where they
have profile-level READ access (via profileUsers table). The server
generates a scoped JWT containing allowedDocumentNames so Tiptap Cloud
enforces per-document access control.
@vercel
Copy link
Contributor

vercel bot commented Feb 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview Feb 16, 2026 9:41pm

Request Review

READ permission allowed read-only users to receive a write-capable JWT,
bypassing the UPDATE gate enforced by updateProposal.
When Tiptap Cloud rejects an expired or invalid JWT, the handler
invalidates the token query so React Query refetches a fresh token,
which triggers the provider to reconnect.
Refetches the token every 12 hours so the 24h JWT is refreshed well
before expiry, preventing silent disconnects for long sessions.
Moves DB lookup, authorization, and token generation out of the tRPC
handler into a service function, matching the pattern used by every
other proposal endpoint. Now uses assertInstanceProfileAccess with
org-level fallback instead of a bare checkPermission call.
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