Security Model
AMS is built with security as a first-class concern โ from multi-layer authentication to tenant isolation, rate limiting, encryption, and compliance features.
Authentication
AMS uses Laravel Sanctum for authentication, supporting two modes:
- SPA Authentication โ The web frontend authenticates via encrypted, HTTP-only cookies using Laravel's stateful auth. CSRF tokens protect all state-changing requests.
- API Token Authentication โ Third-party clients use Bearer tokens generated via the API or admin panel. Tokens are hashed with SHA-256 before storage โ even if the database is compromised, raw tokens cannot be recovered.
curl -X POST https://pasha.ams.hkus1.s4s.host/api/v1/admin/api-tokens \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Zapier Integration", "abilities": ["members:read", "events:read", "webhooks:write"] }' # Response: {"token": "1|abc123...", "name": "Zapier Integration", ...} # The token is shown ONCE. Store it securely โ it cannot be retrieved again.
Authorization (RBAC)
Authorization is enforced via a Role-Based Access Control (RBAC) system. Every API action is protected by a Policy that checks the user's role and specific permission. Permissions are cached in Redis for 15 minutes and invalidated on role change.
- Roles define a base level of access (Super Admin โ Admin โ Manager โ Staff โ Member)
- Permissions can be granted or revoked individually per role
- All permission checks happen server-side โ client-side UI restrictions are a convenience, not a security control
Tenant Isolation
Every database query is automatically scoped to the current tenant via Eloquent global scopes. This is enforced at the ORM level โ it cannot be bypassed by user input. See Multi-Tenancy for the technical implementation.
CSRF Protection
All state-changing web requests (POST, PUT, PATCH, DELETE) are protected by Laravel's CSRF middleware. The CSRF token is embedded in every form and SPA request. API token routes are exempt from CSRF (they use Bearer tokens instead).
Rate Limiting
| Endpoint Type | Rate Limit | Window | Response on Breach |
|---|---|---|---|
| Authenticated API requests | 60 requests | per minute | 429 Too Many Requests |
| Unauthenticated API requests | 10 requests | per minute | 429 Too Many Requests |
| Login / auth endpoints | 5 requests | per minute | 429 + 30s lockout |
| Password reset | 3 requests | per hour | 429 Too Many Requests |
| File upload | 20 requests | per minute | 429 Too Many Requests |
| Webhook delivery (outbound) | Unlimited | โ | Queued with exponential backoff |
Rate limit headers are returned on every response:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 47
X-RateLimit-Reset: 1741953600
Retry-After: 23 # Only present on 429 responses
Data Encryption
- In Transit โ All data is encrypted with TLS 1.3. HTTP is automatically redirected to HTTPS. HSTS headers enforce this in browsers.
- At Rest (Database) โ Sensitive fields (payment tokens, OAuth secrets, private keys) are encrypted using AES-256-GCM via Laravel's
Cryptfacade before storage. - At Rest (Files) โ Files stored in S3 use server-side encryption (SSE-S3). Files served via pre-signed URLs with 1-hour expiry.
- Passwords โ Hashed with bcrypt (cost factor 12). Never stored in plain text.
- API Tokens โ Stored as SHA-256 hashes. The plaintext token is shown only once on creation.
GDPR Compliance Features
| Feature | Location | Description |
|---|---|---|
| Data Export | Member profile โ Export My Data | Members can download all their data as JSON/CSV |
| Account Deletion | Member profile โ Delete Account | Soft delete with 30-day recovery window, then hard delete |
| Consent Tracking | Communications module | Email/SMS opt-in/out tracked per member per channel |
| Data Retention | Settings โ Data Retention | Configurable retention periods per data type |
| Audit Log | Admin โ Audit Log | All admin actions logged with timestamp and user |
| Privacy Policy URL | Settings โ Legal | Displayed on registration and login pages |
Audit Logging
Every significant action in AMS is recorded in the audit log with: timestamp, actor (user ID + name), action type, affected resource, old values, new values, and IP address. Audit logs are immutable โ they cannot be edited or deleted by any role including Super Admin.
{
"id": "log_01HXZB",
"timestamp": "2026-03-14T09:32:11Z",
"actor": { "id": "usr_01HX", "name": "Ahmed Khan", "role": "admin" },
"action": "member.updated",
"resource": { "type": "member", "id": "mem_01HY" },
"changes": {
"membership_type": { "from": "associate", "to": "full" }
},
"ip_address": "203.0.113.45"
}
Password Policies
AMS enforces the following password policy for all users (configurable by tenant admins):
- Minimum 8 characters (recommended: 12+)
- Must contain at least one uppercase letter, one lowercase letter, one digit, and one special character
- Password history: last 5 passwords cannot be reused
- Password expiry: configurable (default: no expiry)
- Breached password detection via HaveIBeenPwned API (optional)
Two-Factor Authentication
Security Headers
| Header | Value | Purpose |
|---|---|---|
| Strict-Transport-Security | max-age=31536000; includeSubDomains | Enforces HTTPS for 1 year |
| X-Content-Type-Options | nosniff | Prevents MIME type sniffing |
| X-Frame-Options | SAMEORIGIN | Prevents clickjacking |
| X-XSS-Protection | 1; mode=block | Legacy XSS browser filter |
| Referrer-Policy | strict-origin-when-cross-origin | Controls referrer info |
| Content-Security-Policy | Configured per environment | Prevents XSS, injection attacks |
| Permissions-Policy | camera=(), microphone=(), geolocation=() | Disables unused browser features |
Vulnerability Disclosure
If you discover a security vulnerability in AMS Platform, please report it responsibly. Do not create a public GitHub issue or post on social media before we've had a chance to address it.
- Email: security@ams.hkus1.s4s.host
- Response time: Initial acknowledgement within 24 hours, fix within 7 business days for critical issues
- Scope: The AMS web application, API, and admin panel. Excludes third-party services (Stripe, Twilio, etc.)
- Reward: We publicly credit researchers who report valid vulnerabilities (with their permission)