Skip to content

Commit 13704d4

Browse files
authored
Merge commit from fork
Require authentication for thumbnail image access
2 parents 0a01435 + dbe5157 commit 13704d4

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

octoprint_prusaslicerthumbnails/__init__.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,37 @@ def get_extension_tree(self, *args, **kwargs):
345345

346346
# ~~ Routes hook
347347
def route_hook(self, server_routes, *args, **kwargs):
348-
from octoprint.server.util.tornado import LargeResponseHandler, path_validation_factory
348+
from octoprint.server import app
349+
from octoprint.server.util.flask import (
350+
permission_validator,
351+
)
352+
from octoprint.server.util.tornado import (
353+
LargeResponseHandler,
354+
access_validation_factory,
355+
path_validation_factory,
356+
)
349357
from octoprint.util import is_hidden_path
358+
350359
thumbnail_root_path = self._file_manager.path_on_disk("local", "") if self._settings.get_boolean(["use_uploads_folder"]) else self.get_plugin_data_folder()
360+
351361
return [
352-
(r"thumbnail/(.*)", LargeResponseHandler,
353-
{'path': thumbnail_root_path, 'as_attachment': False, 'path_validation': path_validation_factory(
354-
lambda path: not is_hidden_path(path), status_code=404)})
362+
(
363+
r"thumbnail/(.*)",
364+
LargeResponseHandler,
365+
{
366+
'path': thumbnail_root_path,
367+
'as_attachment': False,
368+
'path_validation': path_validation_factory(
369+
lambda path: not is_hidden_path(path),
370+
status_code=404
371+
),
372+
"access_validation": access_validation_factory(
373+
app,
374+
permission_validator,
375+
Permissions.FILES_LIST,
376+
),
377+
}
378+
)
355379
]
356380

357381
# ~~ Server API Before Request Hook

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
plugin_name = "Slicer Thumbnails"
1515

1616
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
17-
plugin_version = "1.1.0"
17+
plugin_version = "1.2.0"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module

0 commit comments

Comments
 (0)