By jdkealy

2015-06-22 19:59:28 8 Comments

If I have a single server with multiple domains, what is the preferred method for implementing a single-sign-on solution on the same domain. I am currently using devise, have a few million cookies in place on separate domains, and am stuck. On top of just implementing SSO, I also need to migrate the various cookies to a central domain. Regarding the various servers, they only have one single page that requires me to show different states depending on whether or not the user is logged in.

I have tried the following:

  1. CORS: pick one domain as the central auth hub. From all other domains make cross domain checks to see if the user is logged in. For migrating cookies, detect if there's a "current_user" object, send it to the client, make a CORS request, sign the user in and kill the token. Works Great! BUT... After building it for 2-3 weeks, it TOTALLY FAILS in IE. Even IE11, I'm noticing the default setting is disabling this behavior.

  2. tried tinkering with the session store at


with no luck.

I am currently experimenting with the following:

  1. JSONP: I have someone right now trying to convert the above to JSONP instead while I try some other options:

  2. Set up a custom OAUTH provider. Like before, it will be the "central domain" if the person is signed in, return to the requested domain with a token from which the users can make requests.

  3. Looking at this but it looks outdated? I also get the feeling this could have been a solution if I rolled this out from the get-go, but given how far we are into the project, it's unclear to me how I'd transfer the existing cookies. Also it's unclear if this requires two applications for me to get up and running ( one for client(s), one for auth server)

As I go through each of these possibilities, if anyone has had any experience doing what I'm doing, please do inform me and save me a whole lot of work :)


@Nick 2015-07-02 21:45:54

The best way unless this is a toy app is probably to set up an oauth provider.

We use Doorkeeper with Devise for this and it works great. It will be worth your time to set a little time aside to read through the documentation and watch a talk or two on youtube if you're not already familiar with the strategy but once you understand the core concepts its actually pretty simple to set up with the help of this gem.

There is a quick video run down on

Related Questions

Sponsored Content

4 Answered Questions

[SOLVED] Why is it common to put CSRF prevention tokens in cookies?

31 Answered Questions

[SOLVED] Access-Control-Allow-Origin Multiple Origin Domains?

14 Answered Questions

[SOLVED] How to understand nil vs. empty vs. blank in Rails (and Ruby)

  • 2009-05-19 22:51:36
  • Arrel
  • 304113 View
  • 1117 Score
  • 14 Answer
  • Tags:   ruby-on-rails ruby

18 Answered Questions

[SOLVED] How to "pretty" format JSON output in Ruby on Rails

26 Answered Questions

33 Answered Questions

[SOLVED] How do I get the current absolute URL in Ruby on Rails?

19 Answered Questions

[SOLVED] Purge or recreate a Ruby on Rails database

4 Answered Questions

[SOLVED] Automatic cookie single sign on on multiple domains - like google

Sponsored Content