예제 #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
파일: tests.py 프로젝트: xmulsm/wagtail
 def test_signature_changes_on_filter_spec(self):
     self.assertFalse(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100,
                          'fill-800x700'))
예제 #3
0
파일: tests.py 프로젝트: xmulsm/wagtail
 def test_signature_changes_on_image_id(self):
     self.assertFalse(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 200,
                          'fill-800x600'))
예제 #4
0
파일: tests.py 프로젝트: xmulsm/wagtail
 def test_signature_verification(self):
     self.assertTrue(
         verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100,
                          'fill-800x600'))
예제 #5
0
파일: tests.py 프로젝트: didorothy/wagtail
 def test_signature_changes_on_filter_spec(self):
     self.assertFalse(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x700'))
예제 #6
0
파일: tests.py 프로젝트: didorothy/wagtail
 def test_signature_changes_on_image_id(self):
     self.assertFalse(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 200, 'fill-800x600'))
예제 #7
0
파일: tests.py 프로젝트: didorothy/wagtail
 def test_signature_verification(self):
     self.assertTrue(verify_signature(b'xnZOzQyUg6pkfciqcfRJRosOrGg=', 100, 'fill-800x600'))