Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dropzone #159

Merged
merged 3 commits into from
May 26, 2020
Merged

Fix dropzone #159

merged 3 commits into from
May 26, 2020

Conversation

wilco375
Copy link
Contributor

Summary

Fixes #150
Also, there was no preview shown of the uploaded images because it is shown as a base64 encoded data string which was not allowed by cors policy. That is also fixed with this PR.

@wilco375 wilco375 requested a review from Matthijsy May 25, 2020 13:33
@@ -23,7 +23,7 @@ module.exports = function(environment) {
'script-src': '\'self\' www.google-analytics.com www.googletagmanager.com',
'font-src': '\'self\' fonts.gstatic.com',
'connect-src': '\'self\' sentry.io',
'img-src': '\'self\' camo.csvalpha.nl www.google-analytics.com img.youtube.com',
'img-src': '\'self\' camo.csvalpha.nl www.google-analytics.com img.youtube.com data:',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I like this, this is potentially insecure.

data: Allows data: URIs to be used as a content source. This is insecure; an attacker can also inject arbitrary data: URIs. Use this sparingly and definitely not for scripts.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/img-src

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that's true... Is there any other way to preview the uploaded images, without adding :data to the cors policy?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe blobs? Or check with dropzone itself what the recommend

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is a blob, which is set as the image source as a base64 encoded string. Don't know if there's any other way to set the image source from a blob, but then you basically have the same problem again as described on that site, don't you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created a issue with the package, wondering how other developers handle with this. FutoRicky/ember-cli-dropzonejs#112

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, we'll see what they'll respond with. For the time being, I removed :data from the CSP. For now we'll then at least have a working dropzone, just without preview images.

Copy link
Contributor

@Matthijsy Matthijsy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@github-actions github-actions bot merged commit e97b737 into staging May 26, 2020
@github-actions github-actions bot deleted the bugfix/dropzone branch May 26, 2020 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image dropzone returns 401 when uploading images
2 participants