Sharing authentication between root and subdomain


(Salman, Freelance Developer) #1

Say I am hosting discourse on my domain like:

And my main site, which is a separate Rails app on:

I want to have a login box which simply pushes the username/pwd to the discourse login process, so then when they go to they are already logged in, and also when they are at I can hook into discourse and grab the user’s profile information etc.

Any recommendations on how to go about doing this?

(Doug Harman) #2

I have currently five answers to this / a similar question bookmarked (below). Since javascript isn’t my expertise, I’m getting together with a javascript developer next week to try and resolve it for my new site. I’ll post the outcome for others. Here’s the related q & a:

  1. Issue: Bleeding-edge external SSO prohibits returning to host app
  2. How to use SSO to sign users in to main application and Discourse
  3. Detecting user already logged in when using SSO
  4. How to perform a remote login without changing the domain
  5. Smoothly integrating Discourse with an existing social site

Personally, I think the Discourse team ought to work through this one. However, for now, the solution’s being crowdsourced.

(Kane York) #3

I used an <embed> element for this on an interstitial after-login page.

var embed = document.createElement("embed");

embed.onload = function(){
    // advance login
    window.location = "/login/after-discourse";

embed.src = "";

How can I set cookie/session for my forum from external website?