absinthe-graphql / absinthe_plug

Plug support for Absinthe, the GraphQL toolkit for Elixir
https://hex.pm/packages/absinthe_plug
MIT License
261 stars 163 forks source link

Add support for passing a CSP nonce through to the templates #289

Open jschniper opened 5 months ago

jschniper commented 5 months ago

The changes allow you to pass a csp_nonce_assign_key as an option into the plug and it uses that to pull a nonce from the conn.assigns to add a nonce attribute to the script and link tags.

This is my first hack at it but it seems to resolve the CSP related errors that I was experiencing. Open to suggestions for improvement.

One note: I'm experiencing a JS error on the advanced GraphiQL interface but I'm also experiencing the same error when I run against the current main branch in this repo. Not exactly sure what is going on there but it doesn't seem as though my changes are the cause.