# Pitambari corporate website: operations & security guide

Laravel 13 rebuild of the Joomla site (`H:\xampp\htdocs\pitambari.com`, DB `pitambari_corporate`).
Same template, CSS, images and content; new code, database and security layer.

| | |
|---|---|
| App folder | `H:\xampp\sites\testcorp` (outside `htdocs`, so nothing but `public/` is reachable) |
| Apache vhost | `H:\xampp\apache\conf\extra\httpd-pitambari.conf` (included at the end of `httpd.conf`) |
| URLs | `https://testcorp.pitambaridigitalcare.in/` (test, behind Cloudflare) · locally `https://localhost:8443/`; later `https://www.pitambari.com/` |
| Database | `pitambari_laravel` (web user `pitambari_app`, schema user `pitambari_migrator`) |
| Admin panel | `https://<site>/<ADMIN_PATH>` (see `.env`) |

## Day-to-day

```powershell
# Deploy ANY code / config / asset change (unlocks, migrates, caches, re-baselines, locks read-only):
powershell -ExecutionPolicy Bypass -File H:\xampp\sites\testcorp\deploy.ps1

# Create / reset an admin (console only - there is no sign-up page):
H:\xampp\php\php.exe artisan admin:create vijay.patil@pitambari.com --name="Vijay Patil"
H:\xampp\php\php.exe artisan admin:create someone@pitambari.com --disable

# Security
H:\xampp\php\php.exe artisan security:scan            # integrity check + auto-repair (runs every 2 min)
H:\xampp\php\php.exe artisan security:unblock --list  # banned IPs
H:\xampp\php\php.exe artisan security:unblock 1.2.3.4
H:\xampp\php\php.exe artisan security:audit           # dependency CVE check + daily summary

# Content
H:\xampp\php\php.exe artisan joomla:import            # re-import pages/menus/blocks from Joomla (re-signs content)
H:\xampp\php\php.exe artisan stores:import            # re-import stores from the old Store Locator page
```

> Changing a file without `deploy.ps1` looks exactly like an attack: the next scan reverts it and sends an alert.

## Still to do before go-live

1. **Scheduler:** run `install-scheduler.ps1` once in an elevated PowerShell. Without it the
   2-minute integrity scans and daily audit do not run.
2. **SMTP:** set `MAIL_HOST/PORT/USERNAME/PASSWORD/SCHEME` in `.env`. Until then all mail (enquiries,
   admin OTP codes, security alerts) is only written to `storage/logs/mail-*.log`.
3. **SMS alerts:** set `SMS_DRIVER` (`msg91`, `twilio` or `textlocal`), the provider keys, and
   `SECURITY_ALERT_MOBILES` (comma separated, e.g. `+9198XXXXXXXX`). MSG91 needs a DLT template with a `##message##` variable.
4. **TLS certificate:** replace the self-signed `conf/ssl.crt/pitambari.crt` with a real certificate
   (e.g. win-acme / Let's Encrypt) and set `APP_URL=https://www.pitambari.com`.
5. **Production values in `.env`:** `SHOP_URL=https://www.pitambari.com/shop/`, `APP_TRUSTED_HOSTS`,
   optionally `ADMIN_ALLOWED_IPS` (office IPs) and the reCAPTCHA v3 keys.
6. **Create the admin account** with `admin:create` (above).

## Hosting on IIS instead of Apache

`public\web.config` is the IIS equivalent of the Apache vhost (rewrite rules, request filtering, security headers).
`deploy\iis\setup-iis.ps1` creates the site, app pool, sandboxed PHP FastCGI (`php-pitambari.ini`), the
"only index.php executes" handler mapping and the folder permissions (`-LockDown`). Then deploy with
`deploy.ps1 -Php C:\php\php.exe -Composer C:\php\composer.phar -AppPool Pitambari` and register the scheduler with
`install-scheduler.ps1 -Php C:\php\php.exe`. Set `INTEGRITY_WATCH_FILES` in `.env` to the IIS/PHP config files.

## How each threat is handled

| Threat | Protection |
|---|---|
| SQL injection | Eloquent / bound parameters only; MySQL multi-statements and `LOCAL INFILE` disabled; WAF signatures (UNION, tautologies, time-based, stacked, comment-obfuscated); web DB user has **no DDL, no FILE**, read-only on content tables, insert-only on enquiries/logs |
| XSS | Blade auto-escaping; CSP with per-request nonce, `script-src-attr 'none'`; store-locator JS uses `textContent` only; WAF XSS signatures (multi-level decoding) |
| CSRF | Laravel CSRF tokens on every POST; `SameSite=Strict`, `__Host-` session cookie, encrypted session |
| PHP shells / RCE | Only `public/index.php` may execute; PHP engine off in every asset folder; `.htaccess` ignored (`AllowOverride None`); PHP sandboxed with `open_basedir` and `allow_url_fopen/include off`; uploads inspected (magic bytes, MIME, polyglots, PDF JavaScript, double extensions) and stored outside the web root under random names |
| File alteration / defacement | Signed SHA-256 baseline of every file (code, config, `.env`, all images/CSS/JS) + known-good snapshot; scan every 2 min **restores modified/deleted files, quarantines new files**, alerts by e-mail + SMS; code files read-only; planted `index.html`/`.html` refused by Apache |
| DB content defacement | Every page/block HMAC-signed; a tampered row is **never shown**: the signed snapshot copy is served, an alert is raised, and the scan restores the row; web DB user cannot UPDATE content at all |
| Data exfiltration | Response DLP blocks secrets (APP_KEY, DB password, private keys), stack traces, SQL errors, bulk e-mail/phone dumps not already public, PAN lists, defacement text; outbound HTTP allow-list (SSRF); enquiry PII encrypted at rest (AES-256) |
| Bots | Attack-tool/scraper user agents banned; fake Googlebot/Bingbot (reverse-DNS check) banned; 120 req/min/IP; forms: honeypot field, signed render-time token (too fast / replayed = bot), 3/min & 20/day per IP, optional reCAPTCHA v3; robots.txt bait URL bans instantly |
| Brute force (admin) | Hidden path, optional IP allow-list, e-mailed OTP second factor, 5 tries then 15-min lockout, alert on lockout and on every successful login, 30-min idle logout |
| OWASP A05 misconfig | `APP_DEBUG=false`, `ServerTokens Prod`, `TRACE` off, only GET/HEAD/POST, Host-header allow-list, HSTS, `X-Frame-Options DENY`, `nosniff`, strict Referrer/Permissions policies, request size/time limits, slow-loris timeouts |
| OWASP A06 components | Daily `composer audit` with alert |
| OWASP A09 logging | `security_events` table + `storage/logs/security-*.log` (180 days); critical events alert immediately |

Repeat offenders: 3 strikes in an hour (an injection payload counts double) = 24-hour IP ban.

## DPDP Act 2023: consent

| What | Where |
|---|---|
| Consent on every enquiry form | Short notice + 3 separate, **unticked** boxes: Essential (required to process the enquiry, incl. 18+ confirmation), Marketing (optional), Analytics (optional) |
| Cookie banner | Accept all / Reject non-essential / Customise, equally prominent. Analytics & marketing tags (GA4, Meta Pixel) load **only after opt-in**; "Cookie Settings" in the footer reopens it; turning a category off deletes its cookies |
| Proof of consent | `consents` table: purposes, time, IP, notice version + SHA-256 of the exact wording shown, linked to the enquiry. E-mail stored only as an HMAC so it cannot be read back |
| Withdrawal & rights | `/your-data-rights`: withdraw marketing / analytics / all, access, correction, erasure, nomination, grievance. **E-mail ownership is verified first**: a 6-digit code (10 min, 5 tries, same browser session only, max 3 codes/hour per address and 5/hour per IP) is e-mailed to the address; nothing is recorded or changed until it is entered. Then withdrawal applies immediately and the request (status `email_verified`) is e-mailed to the Grievance Officer with a reference no. |
| Notices | `/privacy-notice`, `/cookie-policy` (wording in `config/privacy.php`, categories/cookies listed there too) |
| Storage limitation | `privacy:purge` (daily 02:30) erases enquiries + résumés after `ENQUIRY_RETENTION_DAYS` (default 365) or as soon as essential consent is withdrawn |
| Marketing team | The enquiry e-mail states **Marketing consent: Yes / NO - do not send marketing**. Before any campaign, check `ConsentLedger::allowsMarketing($email)` (withdrawals respected) |

When the notice or consent wording changes, bump `PRIVACY_NOTICE_VERSION` in `.env`: the cookie banner is shown again
to everyone and new consents are recorded against the new version.

To enable analytics/marketing tags set `ANALYTICS_GA4_ID` / `MARKETING_META_PIXEL_ID` in `.env` and deploy; the CSP
opens the required Google/Meta origins automatically.

## Store locator

Stores live in the `stores` table and are managed in the admin panel. Visitors are located by browser
geolocation (asked once on arrival) or by the pincode they type. Pincodes are resolved locally from the
`pincodes` table (GeoNames India postal codes, CC-BY 4.0), so no visitor data goes to a third party.
Pincode coordinates are locality-level; for an exact pin paste a Google Maps link in the store's
"Exact location" field.
