artisanpack-ui/security
Core Laravel security toolkit for ArtisanPack UI: sanitization, escaping (Laminas Escaper), KSES filtering, validation rules, security/CSP middleware, CSP builder with nonce & reporting, rate limiting, audit/scan commands, and testing helpers.
The ArtisanPack UI Security package provides a comprehensive security configuration file that allows you to manage various security settings for your application. This document explains how to publish and manage this configuration, and how to use the provided tools to validate your setup.
To publish the security configuration file, run the following Artisan command:
php artisan vendor:publish --tag=artisanpack-package-config
This will publish the security.php configuration file to your application's config/artisanpack directory. You can then customize the settings in this file to suit your needs.
The package includes a service to validate your security configuration against best practices. This is especially important in production environments.
The ArtisanPackUI\Security\Services\EnvironmentValidationService is responsible for checking your configuration. In a production environment, it performs the following checks:
app.debug is false.artisanpack.security.encrypt is true.artisanpack.security.enabled is false.'unsafe-inline' or 'unsafe-eval'.These validation checks are run automatically when your application is in a production environment. Any errors or warnings are logged to the application's log file. Errors are logged as critical, and warnings as warning.
You can manually check your security configuration at any time using the security:check-config Artisan command:
php artisan security:check-config
This command will run the validation checks for your current environment and display the results in the console. If any errors are found, the command will exit with a non-zero status code, which can be useful for CI/CD pipelines.
The security configuration fully supports Laravel's configuration caching. When you run php artisan config:cache, your config/artisanpack/security.php file will be cached along with the rest of your application's configuration. The package will correctly use the cached values.
How can I help you explore Laravel packages today?