slackhq / csp-html-webpack-plugin

A plugin which, when combined with HTMLWebpackPlugin, adds CSP tags to the HTML output.
MIT License
164 stars 40 forks source link

Example of using with Helm and multiple environment/values files #86

Closed zleight1 closed 3 years ago

zleight1 commented 3 years ago

Description

Was wondering if anyone was using this with a Helm nginx + configmap deployment where some environments have different values. I'd like to be able to set a domain for test (.test.com) and a domain for production (.prod.com) with the helm chart but also have it work with values files.

Currently our values files have directives set and are overridden as needed with a values.prod.yaml file, etc.

Off the top of my head, I suppose it could be solved by creating multiple output files for each environment and the values file would inject into the config map the proper csp file output, but maybe there is a better solution?

If anyone is doing something similar and has any suggestions or comments please share as I'd like to learn the best process.

What type of issue is this? (place an x in one of the [ ])

Requirements (place an x in each of the [ ])


AnujRNair commented 3 years ago

This plugin is only able to generate hashes and nonces at webpack's compile time - if you're using a runtime variable to conditionally set something, then this unfortunately won't work.

I think your best bet would be to create multiple output files for each env as you have mentioned. That way, webpack can generate the correct hashes and nonces for each file at compile time, and input it into your HTML file