Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] Improve support for non-standard domain names

#6196

Currently when setting domain :all option Rails uses regexp which handles correctly australian and uk styles tld. It is plenty for default behavior, but sometimes we want to use different logic.

For example when dealing with domain like www.app.me the cookie will be set for .www.app.me domain which is not correct. Another example darberry.com.ua - it will be set as .com.ua. And there are plenty of exceptions like this as you can see at http://publicsuffix.org/list.

So I propose a couple of patches to add more flexibility.


First patch adds support for supplying several domain names to cookies. For example,

:domain => %w(.app.me .darberry.com.ua)

And it will set appropriate domain for all cookies.


Second patch adds more flexibility when you deal with wildcard subdomains and they are not correctly parsed by default domain regexp. For example, your application is deployed to subdomain.hosting.com and your application supports subdomains on top so you want to share cookies only between subdomains on top of your application. It's easy to achieve by using custom tld length:

:domain => :all, :tld_length => 3

and it will correctly set cookies domain to .subdomain.hosting.com


https://gist.github.com/734913 - first patch
https://gist.github.com/747615 - second patch

If there is anything I could do to improve these patches I would be happy to do it.

Reported by Ravil Bayramgalin · December 19th, 2010 @ 07:57 PM

State: committed
Milestone: 3.1
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Ravil Bayramgalin
    Ravil Bayramgalin
    • Assigned user changed from José Valim to Santiago Pastorino

    Jose has reviewed patch and said it looks fine, but since he's ill right now, he asked to assign it to Santiago for further review.

    December 25th, 2010 @ 02:50 PM

  2. Santiago Pastorino
    Santiago Pastorino
    • Milestone set to 3.1
    • State changed from new to open
    • Importance changed from to Low

    January 9th, 2011 @ 09:13 PM

  3. Ravil Bayramgalin
    Ravil Bayramgalin
    • Assigned user changed from Santiago Pastorino to Piotr Sarnacki

    Santiago is going on vacation and asked to change it to Piotr :)

    January 14th, 2011 @ 11:53 PM

  4. José Valim
    José Valim
    • State changed from open to committed
    • Assigned user changed from Piotr Sarnacki to José Valim

    January 21st, 2011 @ 12:17 PM