{"id":23900857,"url":"https://github.com/born05/craft-csp","last_synced_at":"2025-04-10T21:03:45.939Z","repository":{"id":54964242,"uuid":"247683122","full_name":"born05/craft-csp","owner":"born05","description":"Content Security Policy (or CSP) generator using nonces.","archived":false,"fork":false,"pushed_at":"2024-08-20T11:45:54.000Z","size":24,"stargazers_count":10,"open_issues_count":0,"forks_count":8,"subscribers_count":8,"default_branch":"craft4","last_synced_at":"2024-09-20T15:38:57.386Z","etag":null,"topics":["content-security-policy","craft-plugin","craft3","craftcms","csp"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/born05.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-16T11:18:04.000Z","updated_at":"2024-09-09T10:23:20.000Z","dependencies_parsed_at":"2024-08-20T13:55:31.358Z","dependency_job_id":null,"html_url":"https://github.com/born05/craft-csp","commit_stats":{"total_commits":28,"total_committers":3,"mean_commits":9.333333333333334,"dds":0.2857142857142857,"last_synced_commit":"613800e67a72af717317a6845ce5ac19fc84ad6e"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/born05%2Fcraft-csp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/born05%2Fcraft-csp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/born05%2Fcraft-csp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/born05%2Fcraft-csp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/born05","download_url":"https://codeload.github.com/born05/craft-csp/tar.gz/refs/heads/craft4","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232518504,"owners_count":18535973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["content-security-policy","craft-plugin","craft3","craftcms","csp"],"created_at":"2025-01-04T20:39:50.907Z","updated_at":"2025-01-04T20:39:51.391Z","avatar_url":"https://github.com/born05.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Content Security Policy plugin for Craft CMS 3.x\n\nContent Security Policy (or CSP) generator using nonces.\n\nCurrently does not work in combination with `{% js %}{% endjs %}` block code twig tags.\n\n## Requirements\n- Craft 4.0.0 and up\n- PHP 8.0.2 and up\n\n## Installation\n\nTo install the plugin, search the plugin store for \"Content Security Policy\" or:\n\n`composer require born05/craft-csp`\n\n## Setting up\n\nEither config using `config/content-security-policy.php` or use nonces:\n\n```twig\n{# Regular html #}\n\u003cscript src=\"url/of/script.js\" nonce=\"{{ cspNonce('script-src') }}\"\u003e\u003c/script\u003e\n\u003clink href=\"url/of/style.css\" rel=\"stylesheet\" nonce=\"{{ cspNonce('style-src') }}\" /\u003e\n\n{# Twig tags #}\n{% css inlineCSS with {nonce: cspNonce('style-src')} %}\n{% js 'example.js' with {nonce: cspNonce('script-src')} %}\n```\n\nExample `config/content-security-policy.php`:\n\n```php\n\u003c?php\n\nreturn [\n    'enabled' =\u003e true,\n    \n    'reportOnly' =\u003e false,\n\n    'baseUri' =\u003e [\n        \"'none'\",\n    ],\n    'defaultSrc' =\u003e [],\n    'scriptSrc' =\u003e [\n        \"'self'\",\n    ],\n    'styleSrc' =\u003e [\n        \"'self'\",\n    ],\n    'imgSrc' =\u003e [\n        \"'self'\",\n    ],\n    'connectSrc' =\u003e [],\n    'fontSrc' =\u003e [],\n    'objectSrc' =\u003e [],\n    'mediaSrc' =\u003e [],\n    'frameSrc' =\u003e [],\n    'sandbox' =\u003e [],\n    'reportUri' =\u003e [],\n    'childSrc' =\u003e [],\n    'formAction' =\u003e [],\n    'frameAncestors' =\u003e [],\n    'pluginTypes' =\u003e [],\n    'reportTo' =\u003e [],\n    'workerSrc' =\u003e [],\n    'manifestSrc' =\u003e [],\n    'navigateTo' =\u003e [],\n];\n```\n\n## Troubleshooting\n\nIf using the SEOMatic plugin, nonces added by that plugin will interfer with this plugin's configuration. You can disable this feature at `/admin/seomatic/plugin#tags` and re-enable the scripts with the following code:\n\n```twig\n{% do seomatic.script.get(\"googleAnalytics\").nonce(cspNonce('script-src')) %}\n```\n\nFor config options see: [Settings.php](https://github.com/born05/craft-csp/blob/craft4/src/models/Settings.php)\n\n## License\n\nCopyright © [Born05](https://www.born05.com/)\n\nSee [license](https://github.com/born05/craft-csp/blob/craft4/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborn05%2Fcraft-csp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborn05%2Fcraft-csp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborn05%2Fcraft-csp/lists"}