Skip to content

Warp tunnel: verify OAuth access tokens so 'decocms link' can use per-user auth #3284

@tlgimenes

Description

@tlgimenes

Background

bunx decocms link (added in #3282, fixed in #3283) opens a tunnel through the Warp server (@deco-cx/warp-node). Today the tunnel is authenticated with a hardcoded shared key (DECO_TUNNEL_SERVER_TOKEN, with a fallback constant in the CLI source) — every CLI install uses the same secret.

PR #3282 pivoted the CLI auth flow to standard OAuth 2.1 + PKCE against Better Auth's MCP plugin, which means each user now has their own access token in ~/.deco/session.json. The CLI was originally wired to send that access token as the Warp apiKey, but the Warp server doesn't know how to verify it — it dropped the registration silently and the CLI hung indefinitely. PR #3283 reverted to the shared key as a stop-gap.

Goal

Update the Warp tunnel server so it accepts the user's OAuth access token (or an equivalent per-user credential) for the register handshake, and rejects requests that don't carry a valid one.

What to do

  1. On the Warp server side:

    • Accept an OAuth bearer token in the existing apiKey field of the register message (or read from a new Authorization header — TBD which is cleaner).
    • Validate the token against the decocms auth server (introspect via JWT signature + issuer, or hit a verification endpoint).
    • Reject (with an explicit error message) registrations whose token is missing, expired, or invalid — currently rejection is silent.
    • Optionally: bind the requested subdomain to the token's `sub` so a user can only register subdomains derived from their own identity.
  2. On the CLI side (one-line change once Warp is ready):

  3. Token refresh (nice-to-have, not strictly blocking):

    • The CLI session already persists refreshToken and expiresAt from the OAuth response. Add transparent refresh in the CLI (or document that users re-run `auth login` on expiry) so long-running tunnels survive token rotation.

References

Acceptance

  • A decocms link running against a Warp server that has been updated to verify OAuth tokens succeeds end-to-end without the legacy shared key.
  • An invalid or missing token results in a fast, explicit error message on the CLI within 15s, not a hang.
  • The shared DECO_TUNNEL_SERVER_TOKEN constant is removed from the CLI source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions