diff --git a/frigate/api/media_auth.py b/frigate/api/media_auth.py index 49a3e6f8f9..442b4d9087 100644 --- a/frigate/api/media_auth.py +++ b/frigate/api/media_auth.py @@ -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 diff --git a/frigate/test/test_media_auth.py b/frigate/test/test_media_auth.py index 98a84a74c9..c47cd1e156 100644 --- a/frigate/test/test_media_auth.py +++ b/frigate/test/test_media_auth.py @@ -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(