-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Adds authentication to file retrieval #3897
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
Conversation
I have a website that shows financial documents and the URL are accessible to anybody that has the URL. What would a URL look like in a img tag vs /files route are they the same? |
@dplewis I'm pretty sure they would be the same. |
@hhanesand thanks that's what I thought |
@dplewis yup, they'd be the same. For any file type, you just need to append |
@davidrichard23 would you be against an implementation based upon a HTTP header instead of one that overloads the path? I would probably make for clearer error messages. |
Also there's a bug flow in the design of that feature, any logged in user has access to it's own profile, which would make an easy path to build, and therefore able to access any file protected with those accesses. |
I don't really have too much experience dealing with HTTP headers, but after looking into it a little, I think you're right, it would be better. I'll try to update it. |
Can you share more details on this? I'm not sure I understand fully |
I understand you want to authenticate the file retrieval based on the ability of a particular session token to a particular object. |
Maybe I'm missing something. The auth function queries for the file at the specified key in the specified class using the filename. If the key or class is changed by a malicious user, the auth would fail because the query wouldn't find the file in whatever class/key the malicious user used because a file with that name doesn't exist in that location, right? |
Yeah, I missed that part sorry. Also I don't see any tests |
I'm new to this whole process, sorry. Where would the test go? I don't see a spec file for for FilesRouter. Should I create one or should I place the test in a different file? |
Yes you can add the tests in a new |
@@ -10,7 +10,7 @@ export class FilesRouter { | |||
|
|||
expressRouter(options = {}) { | |||
var router = express.Router(); | |||
router.get('/files/:appId/:filename', this.getHandler); | |||
router.get('/files/:appId/:filename/:referencingClass?/:referencingKey?/:sessionToken?', this.getHandler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we split the 2 endpoints for the sake a readability and ease of maintenance?
This way the endpoint that validates the auth calls the getHandler
if everything is authorized. This will remove the clutter in the getHandler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even better probably make it a middleware to not clutter the logic inside the function
Sorry for the delay, I've been super busy with work. I'll try and get to it soon! |
Why not use the _id of the document for faster search? The sessionToken is not always required, in some cases the file may be public. Thanks |
The code is missing:
before making the rest request. Thanks |
Any updates on this functionality? I would also find it useful to have authentication for accessing particular files. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is my first time contributing so I'm not sure if this was the appropriate way to add this feature. Please let me know if there was a better way or any other pointers you have. Thanks!
#3887