Craft CMS plugin that serves /.well-known/security.txt
(RFC 9116) per site, maintained in the control panel
under security.txt.
- Confirmed validity —
Expiresis one year after the details were last confirmed (built onmindtwo/base-security-txt). The form ends with the validity and a Confirm details button that stores the fields and renews the validity for one year; Save changes in the header stores them and keeps the date. The very first save publishes the file. Nobody edits a date, and a file nobody confirms expires. - Reminder — from 30 days before expiry, users with access see a control panel alert on every page with a Check now link to the security.txt page.
- Editable in production — the content lives in the plugin's own table, not in project config,
so it works with
allowAdminChangesdisabled. Access is granted with the regular Access security.txt user permission. - Fields — Contact (required, one per line: e-mail,
+phone number or https URL), Policy, Encryption, Acknowledgments, Hiring, Preferred languages.Canonicalis added automatically on https sites. - Safe defaults — invalid input is rejected with field errors and the published file stays
unchanged; without a contact the URL answers 404.
/security.txtredirects (301) to the well-known path. - Multi-site — one file per site, with a site switcher in the control panel.
- English and German interface.
composer require mindtwo/craftcms-security-txt
php craft plugin/install mindtwo-security-txtThen open security.txt in the control panel, enter the contact and save.
Requirements: Craft CMS 4 or 5, PHP 8.0.2+.
- A route for
.well-known/security.txtorsecurity.txtinconfig/routes.phpwins over the plugin. When switching from such a project-level solution, remove the route after entering the contact in the plugin. - Responses are sent with
Cache-Control: public, max-age=3600, so a CDN shows changes within an hour at the latest.
composer install
composer check # pint --test, phpstan (level 8), pestInside the monorepo the core resolves through the path repository base-security-txt; CI removes it
when the package is built standalone.
MIT, see LICENSE.md.