fix: resolve generated-output downloads per user - #800
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Looks like this landed upstream independently. 712d413 added deeptutor/api/routers/outputs.py, which serves outputs through a request-scoped path service and fails closed with a 404 when there is no authenticated user, and tests/api/test_output_files.py covers #790 directly. I compared the two before saying anything: resolve_public_output_path already handles what my tests exercised, traversal outside the outputs root, private suffixes, and non-files. Its docstring also makes a fair point about the shape I used, which validated against one workspace and then rebuilt the path from another root. Happy to close this out. Let me know if there is anything here worth keeping instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Update
SafeOutputStaticFilesindeeptutor/api/main.pyto select aPathServicefor each request instead of delegating lookup to the startup-boundStaticFiles.directory: read thedt_tokencookie from the ASGI request, decode it through the existing auth service, convert the payload through the existing multi-user identity mapping, and resolve that scope withget_path_service_for_scope. Resolve and serve the requested file against that service's public-output root only afteris_public_output_pathaccepts it, so validation and physical lookup use the same account root. Preserve the default service only for auth-disabled/local-admin operation; when authentication is enabled, a missing or invalid credential should return the same non-revealing 404 rather than falling back to another account's files.SafeOutputStaticFilesis constructed at application startup with the defaultPathService, so its Starlette directory remains rooted at the admin output tree for every request. Generated files for authenticated non-admin users are written beneathdata/users/<uid>/user, causing otherwise valid/api/outputs/...links to return 404 even though the artifact exists. The bundle provides a concrete reproduction and diagnosis, and the current code still contains the startup-bound mount; there are no competing or prior cross-referenced PRs. The fix must preserve the existing public-output whitelist, private-suffix rejection, traversal protection, and account isolation.Closes #790
Related Issues
Module(s) Affected
agentsNot claimed: the workspace test run did not pass; see the notes above.
apiNot claimed: the workspace test run did not pass; see the notes above.
configNot claimed: the workspace test run did not pass; see the notes above.
coreNot claimed: the workspace test run did not pass; see the notes above.
knowledgeNot claimed: the workspace test run did not pass; see the notes above.
loggingNot claimed: the workspace test run did not pass; see the notes above.
servicesNot claimed: the workspace test run did not pass; see the notes above.
toolsNot claimed: the workspace test run did not pass; see the notes above.
utilsNot claimed: the workspace test run did not pass; see the notes above.
web(Frontend)Not claimed: the workspace test run did not pass; see the notes above.
docs(Documentation)Not claimed: the workspace test run did not pass; see the notes above.
scriptsNot claimed: the workspace test run did not pass; see the notes above.
testsNot claimed: the workspace test run did not pass; see the notes above.
...Not claimed: the workspace test run did not pass; see the notes above.
Checklist
pre-commit run --all-filesand fixed any issues.Not claimed: the workspace test run did not pass; see the notes above.
Additional Notes
Add any other context or screenshots about the pull request here.