Module: WhereIsWaldo::JwtConnection
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/channels/where_is_waldo/jwt_connection.rb
Overview
Turnkey ActionCable connection auth for corebyscott apps. The cable client
appends the user's JWT as ?token=...; this decodes it via
Corebyscott::JwtService and identifies the connection by the authenticated
user (the presence subject), the JWT's container (cid), and session (jti).
# app/channels/application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
include WhereIsWaldo::JwtConnection
end
end
The subject model comes from WhereIsWaldo.configuration.subject_class (e.g. "User"); the container class from Corebyscott.config. Opt-in: only include it in apps that authenticate with corebyscott JWTs.
Instance Method Summary collapse
Instance Method Details
#connect ⇒ Object
26 27 28 29 30 |
# File 'app/channels/where_is_waldo/jwt_connection.rb', line 26 def connect self.current_user = wiw_verified_user self.current_container = wiw_container self.session_id = wiw_session_id end |