ruilisi / actioncable-jwt

Actioncable with authentication by jwt token

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Action Cable Jwt

This package provides authentication through JWT for action cable and other features. The recommended ways for handling connections of acitoncable-jwt are:

Install

npm install --save actioncable-jwt
yarn add actioncable-jwt

Usage

import { createConsumer } from 'actioncable-jwt'
const consumer = createConsumer(ACTIONCABLE_URL, JWT_TOKNE) 

Features

Besides that this package is setup as a standalone action cable project, features below are provided:

  • Authenticate through jwt token

    It is solved simply by appending jwt token in the Sec-WebSocket-Protocol of the headers of initial WebSocket connection's.

  • Make action cable compatible with SSR frameworks , ex., Nextjs.

    The original generated action_cable.js attaches self value which can't be recognized by backend's Node server. It is solved by one line config in rollup.config.js

    
    intro: "var self = typeof window !== 'undefined' ? window : global;"
    
  • Generate the asset in production mode

  • The original actioncable package does not deal with backend disconnection event with an unauthorized reason, this package does.

About

Actioncable with authentication by jwt token

License:MIT License


Languages

Language:Ruby 81.1%Language:JavaScript 18.9%