Skip to content

Dynamic Schema Loading for Content Security Policy #43

Description

@micchickenburger

The Content Security Policy HTTP header should disallow unsafe-inline as a best practice. However, the schema data uses an inline script element.

Some stack overflow links which discuss this problem:

Some of these questions and answers are pretty old, but the general consensus seems to be that loading an external file will not work, but loading a script which generates the JSON+LD script containing the schema data dynamically should work.

A Content Security Policy script-src directive could also include nonces, but this requires a server and may not be suitable for a statically generated site. The directive also supports hashes, but for a blog or site with a lot of pages, one may end up with a unmaintainable quantity of hashes to add to the security header.

This issue is a feature request to add support for Content Security Policies. I think the dynamic generation approach may be the only way.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions