Пример #1
0
    def get(self, request, signature, image_id, filter_spec, slug):
        if not verify_signature(
                signature.encode(), image_id, filter_spec, key=self.key):
            raise PermissionDenied

        image = get_object_or_404(self.model, id=image_id, slug=slug)

        # Get/generate the rendition
        try:
            rendition = image.get_rendition(filter_spec)
        except SourceImageIOError:
            return HttpResponse("Source image file not found",
                                content_type='text/plain',
                                status=410)
        except InvalidFilterSpecError:
            return HttpResponse("Invalid filter spec: " + filter_spec,
                                content_type='text/plain',
                                status=400)

        return getattr(self, self.action)(rendition)
Пример #2
0
 def test_signature_changes_on_filter_spec(self):
     self.assertFalse(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100,
                          'fill-800x700'))
Пример #3
0
 def test_signature_changes_on_image_id(self):
     self.assertFalse(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 200,
                          'fill-800x600'))
Пример #4
0
 def test_signature_verification(self):
     self.assertTrue(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100,
                          'fill-800x600'))
Пример #5
0
 def test_signature_changes_on_filter_spec(self):
     self.assertFalse(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x700'))
Пример #6
0
 def test_signature_changes_on_image_id(self):
     self.assertFalse(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 200, 'fill-800x600'))
Пример #7
0
 def test_signature_verification(self):
     self.assertTrue(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x600'))