Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to pass CSRF token on authenticate? #3

Closed
nickelser opened this issue Feb 28, 2011 · 5 comments
Closed

Way to pass CSRF token on authenticate? #3

nickelser opened this issue Feb 28, 2011 · 5 comments

Comments

@nickelser
Copy link

Right now I have to use a slightly modified version of pusher.js instead of the hosted one, as right now pusher does not set "X-CSRF-Token" which is required by my rails app. I'm not entirely sure what the best way to do this on a global level would be, but I added a line like this to make it work:

xhr.setRequestHeader("X-CSRF-Token", Pusher.csrf_token)

(and set Pusher.csrf_token = $('meta[name="csrf-token"]').attr('content') before calling pusher init).

@borski
Copy link

borski commented Jul 6, 2011

I have this same issue. nickelser: Can you be more specific as to how you got around this?

@nickelser
Copy link
Author

make sure you are including the csrf_meta_tags helper in your view, run the Pusher.csrf_token = $... code in some global init block, and then run setrequestheader in the ajaxsetup call.

in coffeescript, I have a function like this:

init_csrf = ->
  window._settings.token = $('meta[name="csrf-token"]').attr 'content'

  $.ajaxSetup
    beforeSend: (xhr) ->
      xhr.setRequestHeader "X-CSRF-Token", _settings.token

mloughran pushed a commit that referenced this issue Sep 21, 2011
Fix issue #9 (Bind to the online & offline event with addEventListener)
@ThisIsMissEm
Copy link
Contributor

This isn't actually yet done, I'm working on a patch this week which should be released in the next couple of weeks.

@brumm
Copy link

brumm commented Jan 24, 2012

I'm having this problem as well, and it's been a while - Any progress on this?

@leggetter
Copy link
Contributor

It's possible to pass additional parameters to be passed along with channel_name and socket_id by passing additional options to the Pusher constructor. This provides a way of defining additional query parameters and headers.

You can read the documentation here:
http://pusher.com/docs/client_api_guide/client_connect#options_parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants