Download the PHP package pitbphp/security-starter without Composer
On this page you can find all versions of the php package pitbphp/security-starter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package security-starter
PITB Security Starter
Laravel package implementing PITB Application Security Procedure controls.
Requirements
| Component | Supported versions |
|---|---|
| PHP | 8.1+ (Laravel 13 needs 8.3+) |
| Laravel | 10.x, 11.x, 12.x, 13.x |
spatie/laravel-permission |
5.11+, 6.x, 7.x, or 8.x |
mews/captcha |
3.3+ (3.4.8+ for Laravel 13) |
Optional: laravel/sanctum (API / hybrid), spatie/laravel-activitylog or owen-it/laravel-auditing (audit driver). Install without a version pin so Composer can resolve a Laravel-compatible release.
Installation
After the first composer require, Composer will ask whether to run setup now (interactive terminals only). If you confirm, you choose auditing driver, runtime mode, and security tier once in Composer; those choices are passed to security:install with --no-interaction so you are not prompted again. Run php artisan security:install directly anytime for the full interactive wizard.
A marker file is written to storage/app/pitb-security-installed when install completes. Existing setups with config/security.php are also treated as already installed.
This will (once):
- Ask which auditing library to use (
activitylog,auditing, ornone) - Ask which runtime mode to secure (
web,api, orhybrid) - Install the matching Composer package with a Laravel-compatible version
- Publish config, migrations, and dependency configs (
captcha.php,permission.php,activitylog.phporaudit.php). Views and front-end assets are published only forwebandhybrid— not forapimode. - Publish and run auditing package migrations (
activity_logorauditstable) - Run package and permission migrations
- Ask whether to seed default PITB roles and permissions
Use --driver=activitylog --mode=hybrid to skip prompts, --mode=api for JSON-only API apps (no Blade views), --skip-seed to skip RBAC seeding, or --skip-composer if you install auditing packages yourself.
If the app has not run baseline Laravel migrations yet (for example users table is missing), install automatically runs php artisan migrate first as a fallback before package migrations.
If you skip seeding, update config/security.php (security.permissions.permissions and security.permissions.roles) and run:
Re-publish dependency configs only (without re-running full install):
config/security.php is the source of truth for feature toggles. Vendor configs (captcha.php, activitylog.php, permission.php, audit.php) hold package-specific settings only.
At runtime the package mirrors security settings into vendor config keys so they cannot disagree:
security.php |
Mirrored to |
|---|---|
captcha.enabled |
captcha.disable (inverted) |
auditing.driver |
activitylog.enabled / audit.enabled |
permissions.guard |
permission.defaults.guard_name |
logging.retention.audit_trail_months |
activitylog.delete_records_older_than_days |
Legacy vendor env keys (CAPTCHA_DISABLE, ACTIVITY_LOGGER_ENABLED, AUDITING_ENABLED, PERMISSION_GUARD) are no longer required and should be removed when present.
Run php artisan security:doctor to detect legacy/env drift and then clear config cache.
Publish customizable views (web / hybrid only)
Skip this section when SECURITY_MODE=api — API mode does not load or require Blade views.
bash php artisan security:integrate-welcome bash php artisan vendor:publish --tag=security-migrations php artisan migrate --path=database/migrations/pitb_security --realpath bash php artisan security:seed-rbac bash php artisan vendor:publish --tag=security-admin-views
→ resources/views/vendor/security/admin/partials/
blade {{-- your-app/resources/views/dashboard/security.blade.php --}} @extends('layouts.app')
@section('content') @include('security::admin.partials.styles') {{-- once per page --}} @include('security::admin.partials.nav')
<h1>Security</h1>
@include('security::admin.partials.users-table', [
'users' => $users,
'filters' => request()->only('search'),
])
@endsection blade
env SECURITY_TIER=moderate bash php artisan security:install --tier=moderate env SECURITY_AUTH_ROUTES=false env SECURITY_MFA_ENABLED=true SECURITY_MFA_METHODS=email,sms SECURITY_MFA_DEFAULT_METHOD=email env SECURITY_SMS_DRIVER=pitb SECURITY_SMS_SECRET_KEY=your-secret-key SECURITY_SMS_DISABLE_SEND=false SECURITY_SMS_LANGUAGE=urdu SECURITY_SMS_RATE_LIMIT_MINUTES=2 env SECURITY_SMS_DRIVER=log bash php artisan migrate bash php artisan vendor:publish --tag=security-views
→ resources/views/vendor/security/auth/, mfa/, password/
blade @include('security::auth.partials.login-form') bash php artisan security:publish-vendor-config --force php artisan storage:link php artisan config:clear blade @include('security::mfa.partials.verify-form') bash php artisan migrate php artisan security:seed-rbac # adds access-requests.* permissions blade @include('security::auth.partials.password-fields') blade @include('security::auth.partials.password-strength') html
html
bash php artisan vendor:publish --tag=security-assets
→ public/vendor/pitb-security/js/pitb-password-strength.js
→ public/vendor/pitb-security/js/pitb-temporary-password.js
env SECURITY_ROUTE_PREFIX=security SECURITY_ROUTE_NAME_PREFIX=security. bash php artisan security:install --mode=api env SECURITY_MODE=api # web | api | hybrid SECURITY_API_GUARD=sanctum SECURITY_API_TOKEN_IDLE_MINUTES=20 SECURITY_API_AUTH_ROUTES=true bash php artisan security:routes php artisan security:routes --json php artisan route:list --name=security bash php artisan vendor:publish --tag=security-routes-api # api mode php artisan vendor:publish --tag=security-routes-web # web mode php artisan vendor:publish --tag=security-routes-hybrid # hybrid mode env SECURITY_API_RESPONSE_ENVELOPE=true bash
1. Login and receive Sanctum token
curl -X POST /api/login -H "Content-Type: application/json" \ -d '{"email":"[email protected]","password":"secret","device_name":"mobile"}'
2. If MFA enabled, verify OTP:
curl -X POST /api/security/mfa/verify \ -H "Authorization: Bearer {token}" \ -d "otp=123456"
3. If password expired:
curl -X POST /api/security/password/update \ -H "Authorization: Bearer {token}" \ -d "password=NewPass123!&password_confirmation=NewPass123!" env SECURITY_MODE=web SECURITY_TIER=strict [email protected],[email protected] SECURITY_AUDIT_DRIVER=activitylog SECURITY_PASSWORD_EXPIRY_DAYS=90 SECURITY_SESSION_IDLE_MINUTES=20 SECURITY_MFA_ENABLED=false SECURITY_CAPTCHA_ENABLED=true SECURITY_ACCESS_PROVISIONING=true SECURITY_DEFAULT_TEMPORARY_PASSWORD= SECURITY_SMS_DRIVER=pitb SECURITY_SMS_SECRET_KEY= SECURITY_SMS_DISABLE_SEND=false SECURITY_SMS_RATE_LIMIT_MINUTES=2 SECURITY_LOCKOUT_ATTEMPTS=5 SECURITY_LOCKOUT_MINUTES=30 SECURITY_LOCKOUT_IP_ATTEMPTS=20 SECURITY_LOCKOUT_IP_MINUTES=15 SECURITY_EVENTS_RETENTION_MONTHS=12 SECURITY_AUDIT_RETENTION_MONTHS=12 SECURITY_REVIEWS_RETENTION_MONTHS=24 SECURITY_ACCESS_REQUESTS_RETENTION_MONTHS=24 bash php artisan security:record-access-review --user=1 --notes="Reviewed admin roles" php artisan security:record-log-review --user=1 --notes="No anomalies" php artisan security:disable-inactive-users --dry-run php artisan security:prune-logs php artisan security:doctor
## Security logging (app code)
Log authentication, authorization, and RBAC events from controllers, services, or jobs without injecting `SecurityEventLogger` on every method.
Use the `SecurityLog` helper:
### Auth events → Security Events UI
For login-related activity (password changes, account actions). Stored in `security_events`.
### RBAC events → Audit Trail
For user/role provisioning. Stored in the audit driver (`activitylog` or `auditing`).
### Authorization events → Security Events UI
For access denials or policy failures.
### Full controller example
| Method | Goes to | Use for |
|--------|---------|---------|
| `SecurityLog::auth()` | `security_events` | Passwords, login, MFA, registration |
| `SecurityLog::authorization()` | `security_events` | Permission/policy denials |
| `SecurityLog::rbac()` | Audit trail | User create/update, roles, access requests |
| `SecurityLog::recordReview()` | `security_reviews` | Manual compliance reviews (artisan commands) |
| `SecurityLog::pruneEvents()` | — | Internal — prunes old `security_events` rows |
`SecurityEventLogger` is the underlying service (singleton). Prefer `SecurityLog` in app code — do not inject `SecurityEventLogger` directly.
### Artisan review commands
Or use the built-in commands: `security:record-access-review`, `security:record-log-review`, `security:record-inactive-review`.
## Auditing drivers
Package events are split across two stores with **no duplication**:
| Destination | What is stored |
|-------------|----------------|
| **Security Events** (`security_events`) | Login, logout, failed login, MFA, password changes/resets, registration submitted, authorization denials, account lockouts |
| **Audit Trail** (Spatie `activity_log` or Owen-It `audits`) | User create/update, role permission changes, RBAC attach/detach, access request workflow, manual reviews, plus your app's own audit entries |
`SECURITY_AUDIT_DRIVER` selects where the audit trail is read from (`activitylog`, `auditing`, or `none`). Auth events always go to `security_events` only; RBAC and provisioning events go to the audit driver only.
**Security Events** (`/security/admin/partials/security-events`) — authentication and access-control activity.
**Audit Trail** (`/security/admin/partials/audit-trail`) — provisioning, RBAC, and application audit records from Spatie Activity Log or Owen-It.
> With `SECURITY_AUDIT_DRIVER=none`, RBAC/provisioning events are not persisted. Use `activitylog` or `auditing` if you need an audit trail.
### Model change auditing (Owen-It)
When `SECURITY_AUDIT_DRIVER=auditing`, add `Auditable` to sensitive models (for example `User`, `Order`). Attribute changes are recorded automatically:
View results under **Audit trail** in the admin partials.
### Custom business events (Spatie Activity Log)
When `SECURITY_AUDIT_DRIVER=activitylog`, log domain actions (order delivered, payment captured, etc.) with Spatie's `activity()` helper. Use a log name per domain (`orders`, `payments`, …) and dot-separated event descriptions:
Optional: add Spatie's `LogsActivity` trait to a model if you want automatic logging on create/update/delete in addition to manual entries.
### Choosing an approach
| Goal | Where it is stored |
|------|-------------------|
| Login, logout, failed login, MFA, passwords | `security_events` → Security Events UI |
| User/role changes, access requests, RBAC | Audit driver → Audit Trail UI |
| “Who changed this model field?” | Owen-It `Auditable` on the model (Audit Trail) |
| “Something happened” (delivered, approved, exported) | Spatie `activity()` with `performedOn` / `causedBy` (Audit Trail) |
| Periodic compliance reviews | `security_reviews` → Reviews UI |
Do not log the same package event twice — auth stays in Security Events; provisioning and RBAC stay in the audit trail.All versions of security-starter with dependencies
composer-plugin-api Version ^2.0
ext-json Version *
illuminate/auth Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/notifications Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
mews/captcha Version ^3.3
spatie/laravel-permission Version ^5.11|^6.0|^7.0|^8.0