-
Notifications
You must be signed in to change notification settings - Fork 2.3k
CSP header causes issues #1464
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
Comments
What's your schema? |
I will need to give you a sample of one dependency that does not work. And also change sensitive info with more non sensitive names. Itll have to wait for tomorrow tho. Thanks so much for the help in advance! |
Turns out is was CSP set up messing for this library. The project without it had it working. |
That's interesting -- how would the CSP affect the behavior of react-jsonschema-form? |
Honestly no clue. Was working from home on a tight schedule. Considering the exact same schema worked on the playground and a small test project I made (simple create react app) , I suspected maybe I had some packages that was ruining for this library somehow. Today a colleague just told me when he commented out the csp, the dependencies worked again like a charm. |
It was a change to the csp that was newly made I believe. I remember it was giving either a warning or an error in the console log. But didnt think it was related to this |
Ok, good it works then! |
@epicfaace can you re-open this issue? we've just been burnt by it too. If you apply a CSP header like:
Then it breaks - we are investigating, I'll report back if we find a way to get the CSP and the package to work together. Then can add to documentation. |
@nathfy any updates? |
@epicfaace the only way we got it working was to add the CSP header containing:
Which is a problem as it allows inline scripts - there is a work around: https://developers.google.com/web/fundamentals/security/csp/#if_you_absolutely_must_use_it_ |
So I encountered the same problem too. Simple way to replicate is to
|
Looks like it might be coming from |
@epicfaace > javascript is not my domain, but yeah looks like the same thing. BTW, CSP can also break on the eval function ... I can also see |
It looks like ajv requires
|
Indeed. AJV is a type of compiler, and it uses the Function constructor with strings that contain code in order to evaluate (i.e. run) the validator that it compiles at run-time. This is effectively the same as It seems viable to me that it might be possible to use ajv-cli to precompile a validator, but there is no path available in The validation code here (which uses AJV) is tightly bound to the form code here. Without offering a means of plugging in a precompiled validator, the most restrictive CSP will still require the use of |
Prerequisites
Description
I get this message spammed at me in console chrome.
I have a huge schema, and I expect the dependencies to work based on boolean values like checkbox.
Steps to Reproduce
Dont know what about my schema is wrong considering it works in playground .
Expected behavior
I expect the dependencies to work, so for a boolean checkbox value, if I answer yes(check the box) I am supposed to get a input field appear.
[What you expected to happen]
Actual behavior
Nothing happens. I get a form with checkbox and when I check it , No input fields arrive. This is one example, considering my schema is big , I have many dependencies but noone work.
WEIRDEST PART IS: in a dummie project, it works. In the playground, it works. BUT NOT IN MINE. AND I commented out everything other than sending the schema I get from backend to the Form.
Version
"react-jsonschema-form": "^1.6.1"
example of console:
( in chrome):

The text was updated successfully, but these errors were encountered: