Skip to content

Render with nonce/hash parameter #847

@screenager

Description

@screenager

As the default installation injects the code just before </body>, the script and assets will be blocked by the browser if you enforce strong CSP headers for injection protection.

It would be nice workaround if by setting 'inject' to false, and rendering the debugbar manually in your master template, one could also add nonce or hash parameter:

$renderer = Debugbar::getJavascriptRenderer();
echo $renderer->renderHead(['nonce' => 'ogCHUYO6kVuNXlvGPcB8dcFIM7p');
..
echo $renderer->render(['nonce' => 'ogCHUYO6kVuNXlvGPcB8dcFIM7p');

so the result would be something like

<link nonce="ogCHUYO6kVuNXlvGPcB8dcFIM7p" ..  />
..
<script type="text/javascript" nonce="ogCHUYO6kVuNXlvGPcB8dcFIM7p">
  var phpdebugbar = new PhpDebugBar.DebugBar();
  ..

Doesn't seem to me that #569 is related, but correct me if I'm wrong

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions