-
Notifications
You must be signed in to change notification settings - Fork 37
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
X-Auth-Token cookie should be set for root path #105
Conversation
updated the handle_auth method to allow for new Meteor versions.
Hi, thanks for the PR. Can you send a link to the change in Meteor that necessitates this change? File-collection uses its own cookie parser, and cookies come from the client-side of the app, not Meteor, so I don't immediately understand how/why this change is necessary. Any additional context you can supply will speed-up my evaluation and testing before being able to accept this change. |
I just noticed when using the example implementation for the login token it actually does not ever set the X-Auth-Token anywhere in the header. I could be missing something though. |
actually use
instead of
|
By "example implementation" are you referring to: https://github.com/vsivsi/meteor-file-sample-app ? If so, then yes, it uses cookies exclusively for authentication because that is the only way to easily get links in Use of the You only need the cookie or the header field, but not both, to successfully authenticate. So I'm still unclear why your proposed change is necessary and what that has to do with Meteor 1.3.2.4. To my knowledge Meteor itself doesn't use cookies, and so I don't know why anything would have changed given that the cookie exchange is between developer (your) client code and file-collection's own route handler that contains its own cookie parser. For me to proceed with this, you need to provide a separate minimal sample application (perhaps based on the sample app, that clearly demonstrates the issue when using Meteor 1.3.2.4. |
As for your suggestion to use |
I apologize it is not a meteor 1.3 issue. The below line is how you configure the X-Auth-Token Correct?
the X-Auth-Token never makes it to the server. Unless I'm missing something obvious, which is possible. |
It also appears that |
Yes, that is how it is done in the sample app. I think the confusion here is that both the HTTP header and the cookie are named So you can define an HTTP header field named
OR You can define a cookie (on the client) named
|
The only mention of https://github.com/meteor/meteor/search?utf8=%E2%9C%93&q=meteor_login_token |
I'm setting the X-Auth-Token using jquery cookie on the client side. However it doesn't seem to be getting passed over to the server side. When i log the actual request I'm receiving it always shows the meteor login token. I wonder if another package is causing this issue. |
Found the issue, I had to set the header in the actual resumable.js headers section via:
|
That works but shouldn't be necessary because the resumable.js XHR requests should pick-up the cookie you set with jQuery. That is how the sample app does it without any difficulty. You do need to be careful to make sure that auth tokens set in cookies / header state (such as in resumable) stay up-to-date with the currently authenticated user, or you can leak credentials after a user logs out and/or another user authenticates. This is why the sample app sets the cookie in a |
Strange I wonder what is different between the two setups |
Yea, and it looks like the meteor-login-token was from the fast-render package. |
Needs to have the correct path setup or else resumable will not pick it up. `$.cookie('x-auth-token', Accounts._storedLoginToken(), { path: '/' });`` |
Hmmm, the sample app uses jQuery to set the cookie and doesn't need to specify the path. I assume the root is the default... Also, cookie names are case sensitive (unlike HTTP request field names) so you're going to need to literally use |
It's one level above where it gets called from. In my app i have |
Got it. Okay, well it seems like you have this sorted out then. |
Yep, thanks for the help. |
Wow, this is super useful! I've been having strange transient issues where users could not display images from uploaded files if they went to my app on a new device / after not accessing it for a long time. I figured it was a cookie issue, but couldn't track it down. Now I see it is likely a path issue, for people going directly to nonroot paths on my site. [https://github.com/carhartl/jquery-cookie says that "By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior). If you want to make it available for instance across the entire domain use Might I suggest modifying the sample app to include |
@edemaine thanks for the suggestion. Can you do a quick PR for that over there? I'm away from my dev box, but can easily review and merge from my phone. |
Fix for Meteor 1.3.2.4 security when uploading a file.
Noticed that my newer Meteor build did not auth correctly using your examples. It doesn't appear to be passing the X-Auth-Token the way that you are expecting it.
updated the handle_auth method to allow for new Meteor versions.