On Tue, Jun 11, 2013 at 3:32 PM, Tomas Ehrlich <
tomas....@gmail.com> wrote:
> Hi Marcin,
> unfortunately it doesn't solve the problem. As it's said in document:
>
> Just like the secret keys, the SESSION_COOKIE_DOMAIN setting from
> OldWebsite.com and NewWebsite.com must match if you want
> to share sessions.
>
> ... but that's possible only when you share sessions in subdomains (eg.
> SESSION_COOKIE_DOMAIN = '.
domain.td' and your sites are
> at
sub1.domain.td,
sub2.domain.td, etc.)
>
>
> Database routing is interesting, but I have one database, one website,
> which is accessed from multiple domains. The problem isn't tied to
> Django nor Python, it's simply limitation of cookies.
>
You could do poor man's SSO, which would be similar to your
<domain>/sess/<sess_id> idea.
Basically, only one of your websites can create a new empty session -
we'll call this the master. If you get a client visit one of your
websites, and they do not have a session on that website, you redirect
them to the master website, with a parameter indicating the source
website.
If they already have a session on the master website, you simply
redirect them to the source website with a token indicating their
(existing) session id.
Otherwise, you create a new session on the master website, and
redirect them back to the source website, again with a token.
When the user returns to the source website, extract the session id
from the token, and set the appropriate cookies so that they are using
that as their session.
Because the session id is hidden behind an opaque token during
transfer, there can be no fixation attacks. Delete the token
immediately after consumption, and you minimise replay attacks.
Cheers
Tom