Implementé un nonce para un csp en línea js. Luchando por encontrar por qué no funciona. Al acceder a una página aparece este error:
Content Security Policy: The page's settings blocked the loading of a resource at https://loca.../script.js ("script-src"). Content Security Policy: The page's settings blocked the loading of a resource at inline ("script-src").Implementado en el matraz: // Dentro del archivo timer.py se implementó una función para crear nonce.
def GetCspNonce(): """Returns a random nonce.""" NONCE_LENGTH = 16 return base64.b64encode(os.urandom(NONCE_LENGTH)) nonce = GetCspNonce() function to redirect to a template: return render_template('base/timer.html', timer= timer, nonce=nonce)// Agregado a init.py csp nonce.
def create_app(): # create and configure the app .... csp = { 'default-src': ['\'self\''], 'script-src': ['https://www.goog....], 'nonce-{nonce}'],...//temporizador.html
<td> <p> ...</p> <script type="text/javascript" src="../static/text/script.js" nonce="{nonce}"></script> </td>