-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a parent_domain option for auth_tkt policy #1028
Conversation
This change adds a new ``parent_domain`` option to ``AuthTktAuthenticationPolicy`` which sets the authentication cookie as a wildcard cookie on the parent domain. This is useful if you have multiple sites sharing the same domain.
Does this actually work? I was under the impression that a subdomain could not set a cookie for a parent domain for security reasons. |
There is some discussion on this on SO: http://serverfault.com/questions/153409/can-subdomain-example-com-set-a-cookie-that-can-be-read-by-example-com |
It works just fine and used very often. |
There are a couple of relevant standards here:
Setting cookies on the parent domain is incredibly useful if you want to share a cookie between multiple services running within a domain. One example of a popular service that uses this is google analytics. If I click around a bit on www.bonprix.de for example I start with GA cookies for just www.bonprix.de but after a few clicks I also get GA cookies for .bonprix.de, which helps google uses to track visits across multiple sites in the same domain. |
+1 |
I'm not sure if this warrants creating an issue or not, but when using the This causes some problems for example when the user logs in on domain.com, does to sub.domain.com, and logs out again on domain.com. This is a bit of a convoluted path, but you can see other potential issues that might arise. I would say if |
Just wanted to note that this has the same problem as an earlier pull request I submitted: #450. When the domain has a multi-part public suffix such as "example.co.uk" it will set the cookie on ".co.uk" instead of the correct "example.co.uk". Here is an example test that fails:
|
@landreville Unfortunately there is not much that Pyramid can do. We don't want to depend on hardcoding the list of "top-level" domain names, nor do we want to depend on packages that do this already. |
This is really the responsibility of the developer to make sure their app is not doing this. They know where it will be hosted, and have control over the settings. |
This change adds a new
parent_domain
option toAuthTktAuthenticationPolicy
which sets the authentication cookie as a wildcard cookie on the parent domain. This is useful if you have multiple sites sharing the same domain.