elixir-error-tracker / error-tracker

🐛 An Elixir-based built-in error reporting and tracking solution
https://hex.pm/packages/error_tracker
Apache License 2.0
383 stars 17 forks source link

Use CSP nonces for script and style tags #61

Closed crbelaus closed 2 months ago

crbelaus commented 2 months ago

This pull request adds a new :csp_nonce_assign_key option to the error_tracker_dashboard/2 macro. If provided, the error tracker will fetch the nonce from the given assign key and use it in the <style> and <script> tags.

This allows using the ErrorTracker dashboard in environments with a restricted content security policy without requiring the usage of unsafe-inline, which should be avoided.

This implementation is based on the Phoenix LiveDashboard one.

I've updated the dev.exs script to use CSP headers. If we remove the new option we will see that the ErrorTracker dashboard doesn't have any styles.

Closes #58