Search code examples
pythondjangodiscourse

How would Auth work between Django and Discourse (working together)


I need a modern looking forum solution that is self hosted (to go with a django project)

The only reasonable thing I can see using is discourse, but that gives me a problem... How can I take care of auth between the two? It will need to be slightly deeper than just auth because I will need a few User tables in my django site as well.

I have been reading about some SSO options, but I am unclear on how to appraoch the problem down the road. here is the process that I have roughly in my head... Let me know if it sounds coherent...

  1. Use Discourse auth (since it already has social auth and profiles and a lot of user tables.

  2. Make some SSO hook for django so that it will accept the Discourse login

  3. Upon account creation of the Discourse User, I will send (from the discourse instance) an API request that will create a user in my django instance with the proper user tables for my django site.

Does this sound like a good idea?


Solution

  • That sounds plausible. To make sure a user is logged in to both, you may put one of the auths in front of the other. For example, if discourse is in front of Django, you can use something like the builtin RemoteUserMiddleware.

    In general, if they are going to be hosted on different domains, take a look at JWT. It has been gainining ground to marry different services and the only thing you need is to be able to decode the JWT token, which a lot of languages have nowadays in the form of libraries.