Giter Site home page Giter Site logo

Comments (7)

khalwat avatar khalwat commented on August 23, 2024

@tomkiss I'm slightly confused, there is no license for Twigpack, it's free?

from craft-twigpack.

khalwat avatar khalwat commented on August 23, 2024

So there's no nonce support currently, but I would be open to adding it if you like.

PRs are welcome too.

from craft-twigpack.

khalwat avatar khalwat commented on August 23, 2024

@tomkiss Where would the value in nonce="" come from? Would it be a constant you pass in, or would it be from the webpack generated hash or...?

from craft-twigpack.

tomkiss avatar tomkiss commented on August 23, 2024

Hi, sorry for the delayed response.

The nonce itself is unique for each request, so wouldn't be part of the build process. I've less experience of nonces on PHP projects and more from React - but I notice that there is a Craft plugin that supports nonces for CSP out there, at least as one implementation example:
https://plugins.craftcms.com/content-security-policy

*RE: "buying a license", lol - I went on a bit of a license-buying rampage and lost track a bit. Aforementioned baby-brain something to do with the confusion perhaps :)

from craft-twigpack.

khalwat avatar khalwat commented on August 23, 2024

So I look a look at the spec: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src

A whitelist for specific inline scripts using a cryptographic nonce (number used once). The server must generate a unique nonce value each time it transmits a policy. It is critical to provide an unguessable nonce, as bypassing a resource’s policy is otherwise trivial. See unsafe inline script for an example. Specifying nonce makes a modern browser ignore 'unsafe-inline' which could still be set for older browsers without nonce support.

The plugin you referenced does it thusly:

https://github.com/born05/craft-csp/blob/master/src/services/Headers.php#L125

It's not clear to me that this is unguessable, but if the random seed is isn't deterministic, I guess it'd be okay.

The rub here is that based on what I read, any nonces that are used in the script/style tags then also appear to need to be sent as part of the header as well.

It seems that to do this right, I'd need to send headers as well as applying the nonce to the script/style tags. Or were you envisioning handling that part yourself?

from craft-twigpack.

khalwat avatar khalwat commented on August 23, 2024

@tomkiss okay I added support for cspNonce in 66a566c

You can set your semVer to dev-develop and do a composer update to pull it down and give it a whirl.

I have not fully tested the implementation yet, so feedback would be great!

from craft-twigpack.

khalwat avatar khalwat commented on August 23, 2024

Added in 1.2.2: https://github.com/nystudio107/craft-twigpack/releases/tag/1.2.2

from craft-twigpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.