-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Content Security Policy nonce option is not working #2066
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required. |
Hi there, I see there is a pull request to fix this bug and already merged. But I still see the same issue now in our application, we are using v1.69.0, tried on latest Chrome and Safari, the same problem. Can someone check this again please? @MglMX |
I have checked and it is still working on version v1.69.0. What CSP are you using for |
@MglMX When I run our application, I see every other mui elements have the nonce added, including materiable-table, but the react-beautiful-dnd (rbd) does not have nonce, see the the style tag and console errors: Here is what inside the style tag: The problem we are facing is, the table and its header, cell data are all working, only the table icons are not showing. Below is how we create the icon:
However, even if I removed everything, only basic table data is there (see below code), I still see the CSP inline-style error. So this error is not caused by my code. Maybe this is caused by the "drag and drop column" feature?
|
You need to specify the nonce to the <MaterialTable
columns={[
{
title: t('permitListPage.id'), field: 'id', defaultSort: 'desc', type: 'string',
},
]}
title={emptyTitle} // const emptyTitle = '';
icons={tableIcons} // import tableIcons from '../TableIcons';
data={permits}
options={{cspNonce: "dX5eH2xW7yW0dC0b"}}
/> The problem with the icons is not related with the CSP. You need to install |
Hi, thanks for the reply. It works as you suggested, the nonce is added to the style tag, and the error is gone. But what is the different between material-table and other material ui components? because for other mui components, the nonce is automatically added by React webpack (I forgot to mention we are using React v16.8.6). If now I have to manually add this nonce in all material-tables in my application, it will be a mess. And if we want to create new tables then we have to remember to add the nonce there as well. Also we are planning to dynamically inject the nonce in our code, then this solution seems not sustainable? |
Material-UI uses JSS to generate the style tags. The nonce used by JSS is taken dynamically from the material-table uses react-beautiful-dnd, which does not use JSS but their own solution to create the style tags. That's why you need to add the nonce here one more time. There is a discussion here on why it is not automatically obtained from the You could create a options={{cspNonce: getCSP()}} |
ah, ok, thanks a lot @MglMX ! I thought the nonce is added by setting webpack_nonce so webpack is generating these tags... For now I will modify all the tables to include the nonce, hope it can be set dynamically in the table in the future. Thanks again for the help! Really appreciated. |
Describe the bug
The possibility to add a
cspNonce
was introduced in this MR #1438.The problem is that
material-table
depends on the packagereact-beautiful-dnd
version11.0.31
which does not have the option to pass acspNonce
as a property.To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
There should be no CSP errors but there is. This is because the react-beautiful-dnd library sets inline styles.
Screenshots
Desktop :
The text was updated successfully, but these errors were encountered: