mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-24 22:37:08 +03:00
deny admin-only media to viewer
The media auth check allowed any role without a camera list before it looked at admin-only paths, so viewer could list and download the face library, classification train and dataset images, and GenAI request frames from /clips/ even though the matching API routes and UI pages are admin-only. Admin-only paths are now denied to every non-admin role before that check.
This commit is contained in:
@@ -311,6 +311,9 @@ def deny_response_for_media_uri(
|
||||
if not role or role == "admin":
|
||||
return None
|
||||
|
||||
if resolution == MediaAuthResolution.ADMIN_ONLY:
|
||||
return 403
|
||||
|
||||
if not is_role_restricted(role, frigate_config):
|
||||
return None
|
||||
|
||||
@@ -319,7 +322,6 @@ def deny_response_for_media_uri(
|
||||
|
||||
if resolution in (
|
||||
MediaAuthResolution.LISTING_MULTI_CAMERA,
|
||||
MediaAuthResolution.ADMIN_ONLY,
|
||||
MediaAuthResolution.UNRESOLVED_MEDIA,
|
||||
):
|
||||
return 403
|
||||
|
||||
@@ -332,6 +332,18 @@ class TestDenyResponseForMediaUri(unittest.TestCase):
|
||||
self.assertIsNone(self._deny("/clips/back_door-1.jpg", "viewer"))
|
||||
self.assertIsNone(self._deny("/clips/", "viewer"))
|
||||
|
||||
def test_unrestricted_role_blocked_admin_only(self):
|
||||
for uri in (
|
||||
"/clips/faces/",
|
||||
"/clips/faces/train/foo.webp",
|
||||
"/clips/faces/alice/ref.webp",
|
||||
"/clips/genai-requests/x/0.jpg",
|
||||
"/clips/preview_restart_cache/x.mp4",
|
||||
"/clips/some_model/train/x.jpg",
|
||||
"/clips/some_model/dataset/cat/x.jpg",
|
||||
):
|
||||
self.assertEqual(self._deny(uri, "viewer"), 403, uri)
|
||||
|
||||
def test_restricted_role_allowed_camera(self):
|
||||
self.assertIsNone(self._deny("/clips/front_door-1.jpg", "limited_user"))
|
||||
self.assertIsNone(
|
||||
|
||||
Reference in New Issue
Block a user