I'm using the tinyMCE html editor in one of my pages. It breaks the Content Security Policies that I have set for the rest of my site.
Chrome gives helpful error messages such as:
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' 'sha256-d6YBI/E1hFs69uzv+OZr4MIn2n/N0Cs0Kkpdv306DoQ=' 'sha256-Ut79aLjs3fC5UtVv26l2r+kyv/4DhifGEM6YG3xXOyo='". Either the 'unsafe-inline' keyword, a hash ('sha256-Ut79aLjs3fC5UtVv26l2r+kyv/4DhifGEM6YG3xXOyo='), or a nonce ('nonce-...') is required to enable inline execution.
But notice that the third hash in the quoted rule is identical to the hash it suggests. Any ideas why it's not accepting that hash?
As a workaround, I tried returning
Ok(EditNoteView(uwid, noteid, filledForm))
.withHeaders(CONTENT_SECURITY_POLICY_HEADER → "default-src 'self' 'unsafe-inline'")
in my controller, thinking that would override the headers set in the
SecurityHeadersFilter. No such luck. The filter replaces any CSP headers already set. Is that the intended behaviour?
For the moment, I'm busy writing my own security headers filter. But I figure there should be a better/easier way. Suggestions welcome.