-
Notifications
You must be signed in to change notification settings - Fork 87
Add env var to suppress the CSP script nonce in development #636
Add env var to suppress the CSP script nonce in development #636
Conversation
I don't think there is anything wrong with the code proposed, however, my only concern is the fact that We are working on a similar approach to disable the CSP in is entirety in development mode for certain use cases, that should also fix the issue with the script nonce for dev tools |
Happy to suitably document those concerns on the env vars page
Oh, great! Is there a branch for this? |
I dont think that change applies here, we are allowing an app to run in dev with no csp. If there is a CSP in your tenancy then its respected still. @guym4c you mentioned that there is a |
@code-forger Sorry, I was referring to the CSP generator we use internally to produce the policy - today it's then always joined to the script nonce by OneApp in the middleware in this PR. The nonce once generated is added the response object (as that needs to be known by OneApp). Do you mean that the script nonce to be used be something that can be overriden (to be empty-string?) by the root module's app config? |
@guym4c I guess it depends, do we want this fix to be 'part of' an application. When someone creates a new application do we want to allow them to add this 'fix' then keep it there in the root module. Alternatively do we want every engineer who comes to work on the project to have to apply this 'fix' locally? |
Should something be added to the docs explaining that we have decided for Firefox, use of the CSP and browser devtools are mutually exclusive? |
I have been discussing with the team and it could be useful to just disable the nonce in development rather than disabling the entire CSP. It is a shame we have to do that just to support a browser but it is a valid use case. @guym4c would you mind solving the conflicts so we can give it another review? thanks 👍 |
# Conflicts: # docs/api/server/Environment-Variables.md
@infoxicator Updated 👍 |
Description
This PR adds an environment variable
ONE_CSP_ALLOW_INLINE_SCRIPTS
that suppresses the script nonce that One App prepends to thescript-src
CSP.Motivation and Context
This will allow inline scripts to be executed in development - for example, to allow browser devtools to inject content scripts in some browsers that otherwise restrict this. (Firefox restricts this due to a long-standing browser bug.)
Other elements of the CSP are configurable through the
developmentAdditions
API, but the script nonce is not - this enables full configuration of the CSP.How Has This Been Tested?
Types of Changes
Checklist:
What is the Impact to Developers Using One App?
This PR enables the use of Firefox for development using OneApp and browser devtools such as those built for React and Redux. I don't think it's realistic to expect developers not to use these tools whilst developing applications using OneApp, and so this PR adds that browser as an option for OneApp developers.