kartik-v / yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 4.x/3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)
Other
229 stars 96 forks source link

Cannot add nonce key to adhere to the CSP policy #188

Open pralhadstha opened 1 year ago

pralhadstha commented 1 year ago

Prerequisites

Steps to reproduce the issue

  1. Use the file widget anywhere and load the page.
  2. This error is found in the console: "[Report Only] Refused to load the stylesheet 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.min.css' because it violates the following Content Security Policy directive: "style-src 'self' 'unsafe-inline'". Note that 'style-src-elem' was not explicitly set, so 'style-src' is used as a fallback. [Report Only] Refused to load the font 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/fonts/bootstrap-icons.woff2?856008caa5eb66df68595e734e59580d' because it violates the following Content Security Policy directive: "font-src 'self'". [Report Only] Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'nonce-< nonce-key >'". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list. "

Expected behavior and actual behavior

When I follow those steps, I see the above issue where I need to whitelist all the URLs and these are the external links I do not want to use in my application. Also, the script tags are missing the nonce key which I cannot add by myself to the source code.

I expected to adhere to the CSP policy by not using external assets links. Also, the script tag needs "nonce-" to adhere to the CSP policy which cannot be added to the script tag by ourselves.

Environment

Browsers

Operating System

Libraries

Isolating the problem