-
Notifications
You must be signed in to change notification settings - Fork 67
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 cookie domain support to Session and Auth snaplets #150
Conversation
It sets same cookie parameters as setSecureCookie. forgetSecureCookie didn't set httpOnly parameter on cookie, which could make some new browsers ignore it.
Hm, I'm not sure info in snapframework/snap-core#212 was correct. I need to double check this. |
Ok, it works all right. Problem was elsewhere. |
So do we need this function? I'm happy to merge if it's needed. |
It may be useful for symmetry with other functions in module. |
So, after doing some research, I've once again studied the rfc6265 which clearly states that HttpOnly and Secure flags don't affect stored cookie replacement.
However @reiddraper reported in snapframework/snap-core#212 that it does matter to some browsers. Maybe he can provide examples of browsers which this affects. So, in my opinion this function should be added for symmetry with other exported functions, better code readability and future-proofing the implementation. |
Maybe actually rework these functions a bit. |
You can set domain name for cookies in auth and cookie session snaplets. This is useful when you want to make stored cookies available to sub-domains. For example: If you set cookie domain to `.example.com`, browser will send it with requests to sub-domains like `api.example.com`,`wiki.example.com` or `sub.subdomain.example.com`. This is a breaking change for public Api. Some snaplets which initialize AuthManager record with named fields like AuthManager { remberCookie = .. } will receive compilation warning only! This includes, for example, a popular snaplet-postgresql-simple Auth Backend.
Seems reasonable to me. @ozataman? |
Seems reasonable to me as well. I agree with symmetricity comments - if we have it on secure cookies now, we may as well expose here also. I am a bit annoyed, though, that the domain cant be dynamically determined in some Handler context. So you'd have to hardwire your production domain text into the codebase, which smells bad. I haven't thought about it enough, but that may be too large a redesign on the auth snaplet for the scope of change here.
|
Add cookie domain support to Session and Auth snaplets
I was using Chrome, somewhere near |
Should be useful for correct cookie handling in custom session/auth implementations.
It sets same cookie parameters as
setSecureCookie
.forgetSecureCookie
didn't set httpOnly parameter on cookie, which could make some new browsers ignore it.