Making a tutorial to integrate Devise with Discourse (with user sync)


(Roberto_Pezzali) #1

Hello everyone. I notice that there are a lot of requests about the integration Discourse inside a rails app.

Devise is maybe the preferred authentication solution for a lot of projects, so I think that maybe a tutorial (or a sample project) to show the best way to integrate a standard Devise installation with Discourse could be very useful.

The objective is very simple:

  1. Main app with Devise installed on www.example.com
  2. Discourse installed on forum.example.com
  3. User registration on the main app
  4. Trasparent login to Discourse
  5. One way user sync
  6. Discourse control panel fixes (hide the possibilità di change email and username)

I can help to create the tutorial and also the sample app on GitHub. There is something similar? Anyone has developed something that I can use as a starting point?


(Erlend Sogge Heggen) #2

If you could make a follow-up tutorial for that which shows how to create a WordPress-Discourse bridge using Devise, I’d throwing my manpanties at you in no time.


(Raitom) #3

Oh god yes ! Could you do it ?


(Bbvoncrumb) #4

Really want to see this!


(Dave Stephens) #5

Did this ever get off the ground? As a Ruby dev, I’d be interested in contributing…


(Roberto_Pezzali) #6

We move to the Official Plugin for SSO


(Dave Stephens) #7

Interesting - how did you hook that into Devise?


(Bcguy) #8

Has anyone here gone through the process of doing this - integrating Devise with Discourse?
How about with both Discourse and with WordPress (for user accounts where the users are rating movies, etc.)?

I’m not technical so will have to hire someone to do this - but was wondering how many hours of work these two efforts might be expected to take?

Any input greatly appreciated.


(Vikhyat Korrapati) #9

Basically what you do to integrate Devise and Discourse authentication is:

  1. Add an auth_token field to your user model.
  2. On sign in in the main application create a cross-domain auth_token cookie with this value and delete it on sign out. This is how you set that up: hummingbird/devise.rb at master · hummingbird-me/hummingbird · GitHub
  3. Set up some means of synchronizing profile information. This involves some code in your Rails application and some in a Discourse plugin. This is how Hummingbird’s works:
    a. discourse-hummingbird/plugin.rb at master · vikhyat/discourse-hummingbird · GitHub
    b. https://github.com/vikhyat/hummingbird/blob/master/app/workers/user_sync_worker.rb
  4. Create a custom user provider like this one: hummingbird/user_sync_worker.rb at master · hummingbird-me/hummingbird · GitHub

(Dave Stephens) #10

This feels like it should be do-able without hacking about with Discourse - the SSO plugin has done that side of the job already. I’m just wondering if anyone has knocked up the Devise side of things.

If not…I guess I’d better get started…


(Sam Saffron) #11

I think you should give it a shot, be sure to post something in the SSO category once you work it out :slight_smile:


(Luke Wright) #12

Did this ever get made? I’m trying to do exactly this and would really appreciate some help from someone that understands how to properly do it. I’m very lost and attempting to get this feature implemented this week.