jeudi 9 novembre 2017

Rails ActionCable with http authentification

I have RoR 5.0.0.1 project with ActionCable functionality. We have staging environmen with http authentification. I need ActionCable to work with our staging. What I need to do to get work ActionCable and http auth in our project? My current connection.rb file:

module ApplicationCable
  class Connection < ActionCable::Connection::Base
    identified_by :current_user

    def connect
      self.current_user = find_verified_user
      logger.add_tags 'ActionCable', current_user.email
    end

    protected
    def find_verified_user
      if verified_user = env['warden'].user
        verified_user
      else
        reject_unauthorized_connection
      end
    end

  end
end

Thanks.

Aucun commentaire:

Enregistrer un commentaire