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.
Common questions about the ArtisanPack Security package.
The package supports Laravel 10.x, 11.x, 12.x, and 13.x. PHP 8.2 or higher is required (Laravel 13 requires PHP 8.3+).
Yes, the package is designed to work alongside Laravel Jetstream and Breeze. However, some features may overlap (like 2FA in Jetstream). You can disable specific features in the configuration to avoid conflicts.
No, it extends and enhances Laravel's authentication system. It uses Laravel's authentication guards and providers as the foundation.
Yes, the package is designed for production use with comprehensive security features, testing, and documentation.
Set the enforcement mode to required:
'twoFactor' => [
'enforcement' => [
'mode' => 'required',
'grace_period_days' => 7, // Give users time to set up
],
],
Yes, users can have TOTP and backup methods (email, SMS) enabled. The primary method is TOTP, with backups available if the user's authenticator app is unavailable.
If you already use Laravel Socialite, you can configure the package to use your existing provider setup:
'social' => [
'enabled' => true,
'link_existing_accounts' => true, // Link social to existing email accounts
],
Users can use recovery codes. If those are also lost, an administrator can disable 2FA:
php artisan 2fa:disable user@example.com --force
Yes, WebAuthn/Passkeys are supported. Enable in configuration:
'webauthn' => [
'enabled' => true,
'relying_party_id' => 'yourdomain.com',
],
It depends on your use case:
Common causes:
See Troubleshooting Guide for solutions.
For mobile apps, consider relaxing IP binding:
'binding' => [
'ip_address' => [
'strictness' => 'none', // Mobile IPs change frequently
],
],
A token can only access what both the token abilities AND user permissions allow.
It depends on use case:
Yes:
$user->tokens()->delete();
Or via CLI:
php artisan token:revoke-all user@example.com
The package uses bearer tokens. For API key style authentication, create a token and use it as an API key in the Authorization header.
Yes, users can have multiple roles, and their permissions are the union of all role permissions.
Configure the super admin role:
'rbac' => [
'super_admin_role' => 'super-admin',
],
Users with this role bypass all permission checks.
[@permission](https://github.com/permission)('edit-posts')
<button>Edit</button>
[@endpermission](https://github.com/endpermission)
[@role](https://github.com/role)('admin')
<a href="/admin">Admin Panel</a>
[@endrole](https://github.com/endrole)
CSP blocks inline scripts by default. Add a nonce:
<script nonce="{{ cspNonce() }}">
// Your code
</script>
Start with report-only in production to identify issues, then switch to enforcement once you've resolved violations.
Add Google's domains to your CSP:
'script-src' => ["'self'", "'nonce'", 'https://www.google-analytics.com'],
See CSP Framework Guide for complete configurations.
Avoid unsafe-inline when possible. Use nonces instead. The only common exception is for CSS in some frameworks that generate inline styles dynamically.
Only allow what your application actually needs. A common safe set:
Avoid executable types (PHP, JS, etc.) unless absolutely necessary.
For user-uploaded content that will be served to other users, malware scanning is strongly recommended. For internal use only, it may be optional.
Use the VirusTotal driver for cloud-based scanning:
'malwareScanning' => [
'driver' => 'virustotal',
'virustotal' => [
'apiKey' => env('VIRUSTOTAL_API_KEY'),
],
],
Note: VirusTotal has API rate limits.
SVG files can contain embedded JavaScript, making them a potential XSS vector. If you need SVG support, sanitize them before serving.
The package provides tools to help with GDPR compliance (data export, consent management, right to erasure), but compliance depends on how you use them and your overall data practices. Consult with a legal professional.
Common recommendations:
Check your industry regulations for specific requirements.
Use the GDPR erasure feature:
use ArtisanPackUI\Security\Services\GdprService;
$gdpr = app(GdprService::class);
$gdpr->processErasureRequest($user);
This handles cascading deletion across related data.
The package is optimized for minimal performance impact. Key optimizations:
Yes, disable unused features to reduce overhead:
'social' => ['enabled' => false],
'webauthn' => ['enabled' => false],
'malwareScanning' => ['enabled' => false],
The package uses Laravel's built-in hashing, which uses bcrypt by default. You can configure Argon2id for additional security:
// config/hashing.php
'driver' => 'argon2id',
The package uses k-anonymity to check passwords against the HIBP database. Only the first 5 characters of the password hash are sent to the API, ensuring the full password is never transmitted.
By default, passwords are allowed if the service is unavailable (failOpen = true). For higher security, set failOpen = false to reject passwords when the service is unavailable.
Do not report security vulnerabilities through public GitHub issues. Contact the maintainers directly through the security contact method specified in the repository.
The package provides test helpers and traits. See Security Testing Guide for comprehensive testing documentation.
Yes, most classes are designed for extension. Bind your custom implementations in a service provider:
$this->app->bind(
\ArtisanPackUI\Security\Contracts\TwoFactorInterface::class,
\App\Security\CustomTwoFactor::class
);
Implement the appropriate interface and register with the package:
use ArtisanPackUI\Security\Contracts\AuthenticationMethodInterface;
class BiometricAuthentication implements AuthenticationMethodInterface
{
// Implementation
}
Yes, the package includes Livewire components for common features. Import and use them in your views:
<livewire:security-dashboard />
<livewire:session-manager />
<livewire:two-factor-setup />
composer update artisanpackui/security
php artisan migrate
php artisan config:clear
php artisan cache:clear
php artisan security:clear-cache --all
Published configuration files won't be overwritten. Check the changelog for any configuration changes and merge them manually.
How can I help you explore Laravel packages today?