Exemplo n.º 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)
Exemplo n.º 2
0
 def test_signature_changes_on_filter_spec(self):
     self.assertFalse(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100,
                          'fill-800x700'))
Exemplo n.º 3
0
 def test_signature_changes_on_image_id(self):
     self.assertFalse(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 200,
                          'fill-800x600'))
Exemplo n.º 4
0
 def test_signature_verification(self):
     self.assertTrue(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100,
                          'fill-800x600'))
Exemplo n.º 5
0
 def test_signature_changes_on_filter_spec(self):
     self.assertFalse(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x700'))
Exemplo n.º 6
0
 def test_signature_changes_on_image_id(self):
     self.assertFalse(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 200, 'fill-800x600'))
Exemplo n.º 7
0
 def test_signature_verification(self):
     self.assertTrue(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x600'))