knock-knock icon indicating copy to clipboard operation
knock-knock copied to clipboard

Unable to Make 'unprotectedUrls' Work as Expected

Open romainpoirier opened this issue 2 years ago • 1 comments

Question

I have a module controller that composes images from raw data using the Intervention image library. When the Knock Knock plugin is disabled, it works as expected, but not when enabled: Intervention can't read the image data.

Here's how I compose the images:

$url = 'https://mywebsite.dev/index.php?p=actions/mymodule/file/view?id=123&token=abc';
$contextOptions = [
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false
    ]
];
$context = stream_context_create($contextOptions);
$imageData = file_get_contents($url, false, $context);
$image = Image::make($imageData);

The script fails at the last line (Image::make).

It appears that my unprotected URLs are not working, as the images aren't readable when Knock Knock is enabled:

'unprotectedUrls' => [
    '/mymodule/file/view/(.*)',
    '/index.php?p=actions/mymodule/file/view(.*)',
    App::env('INTERVENTION_BASE_URL') . '/(.*)'
],

Is there anything wrong here, or is it a Knock Knock bug?

Additional context

No response

romainpoirier avatar Nov 02 '23 09:11 romainpoirier

So a thought I've had firstly is that action endpoints probably shouldn't be protected anyway, as they're pretty crucial to various workings of a site.

Changed for the next release. To get this early, run composer require verbb/knock-knock:"dev-craft-4 as 2.0.10".

engram-design avatar Nov 05 '23 22:11 engram-design

Updated in 2.0.12

engram-design avatar Jul 21 '24 05:07 engram-design