PhoenixKit.Modules.Sync.Web.SocketPlug (phoenix_kit v1.7.43)

Copy Markdown View Source

Plug for handling DB Sync WebSocket connections.

This plug handles the HTTP upgrade to WebSocket and validates the connection code or auth token before handing off to SyncWebsock.

Authentication Methods

Supports two authentication methods:

  1. Session Code (ephemeral) - For manual one-time transfers

    • Query param: ?code=ABC12345
    • Session is tied to LiveView process
  2. Connection Token (permanent) - For persistent connections

    • Query param: ?token=xyz123...
    • Validated against database, subject to access controls

Usage

In your endpoint:

plug PhoenixKit.Modules.Sync.Web.SocketPlug

Or mount at a specific path in router (done automatically by phoenix_kit_socket macro).