Skip to content

Security Patterns

Authorization, encryption, rate-limiting, isolation. The authentication side (passwords, OAuth, JWT) lives in Integrations-Auth.md; this page covers everything that happens after the user is logged in.


RBAC (Role-Based Access Control)

What it is. Users have roles; roles have permissions; the app checks "does this role have permission X?" before letting an action through.

Implementations seen:

CASL (Node)

What it is. Isomorphic ability-checking library. Define ability.can('update', 'Article', { authorId: user.id }) once, use the same logic on server (route guards) and client (UI hiding).

Used in: Workflow Hub.

Spatie/Laravel-Permission

What it is. Laravel's de-facto RBAC package. Roles, permissions, model-level checks via $user->can('publish posts').

Used in: VotigoPro (plus its own role-check and plan-limit middleware).

Custom role checks (middleware / policy)

Most TS apps check a role claim or DB-backed role in middleware (requireRole('admin')).

Used in: - SuperCabs — RoleAssignment model, documented in RBAC.md. - BidIt — Buyer / Seller / Admin. - Sourcing AI — requireOrgSession / requireRole / hasMinRole. - DOC-AI — 30 permissions. - GameTrakker — guest < floor < manager < owner. - AI Concierge — member / admin / owner access policy. - Sell Me A Pen — Permission / RolePermission tables. - Recruiting AI — SUPER_ADMIN plus companyId scoping. - HouseKey — RBAC middleware. - Toolbelt Handyman — SUPER_ADMIN org switcher. - GGPI website — role checks on staff surfaces; scoped, SHA-256-hashed API keys.


Row-Level Security (RLS)

(Not used in the portfolio — covered for comparison.)

What it is. Postgres feature that filters every query by a current_user-aware policy — even if your app code forgets the WHERE tenant_id = ? clause, the database enforces isolation.

Used in: Not used in the portfolio — covered for comparison.

Tradeoffs. Strongest tenant-isolation guarantee available. Adds debugging complexity (queries silently return empty). The portfolio relies on application-layer enforcement instead, which is faster to build but trusts every developer to write correct queries.

Application-layer tenant isolation

What the products do instead: - Toolbelt Handyman — orgId on every query, enforced by an audit gate (npm run test:audit) in CI. - GameTrakker — orgId on every row. - Recruiting AI — companyId scoping. - DOC-AI — org-filtered Qdrant queries and a least-privilege, non-superuser DB role. - SmartForms — tenant-scoped RAG. - AI Concierge — tenant-ownership checks. - Workflow Hub — multi-tenant isolation in the service layer.


CSRF protection

See Integrations-Auth.md — CSRF is auth-adjacent. Used in: GGPI website (CSRF middleware for state-changing requests), Sell Me A Pen (csurf); the Laravel apps (Maximus Pet Store, Pecos River Traders, VotigoPro) use the framework's built-in CSRF token.


Rate limiting

Pattern. Counter per (ip or key, endpoint) with a TTL — in memory, or Redis INCR + EXPIRE — implemented as middleware.

Where it's explicit: - express-rate-limit: GGPI website (login 10 per 15 min, registration 5 per 15 min), Toolbelt Handyman, GoGreen Verify (with a dedicated authLimiter), Sell Me A Pen, APEX, Recruiting AI, Tutor AI, HouseKey. - @fastify/rate-limit: AI Concierge. - Redis-backed: Workflow Hub, Marketing AI, APEX. - Custom limiters: GameTrakker (rate-limit.ts), PoligoPro (rateLimit.ts), Sourcing AI, SmartForms (20 per minute per-user on AI endpoints), Go Green Transit (per-key per-minute plus a monthly cap), DOC-AI (per-org API-key limits), OpenSentinel (rate-limiter-enhanced; also limits tool invocations, MCP calls and webhook receivers).


Connection pooling

Why it matters. Postgres handles a few hundred concurrent connections poorly; serverless platforms create thousands of short-lived ones.

PgBouncer — GoGreen Seller AI only, as a docker-compose.pgbouncer.yml overlay.

ORM / driver pools — every other product (Prisma, Drizzle, SQLAlchemy async, pgx in Marketing AI's Go services).


End-to-End Encryption (E2EE)

(Not used in the portfolio — covered for comparison.)

What it is. Server can't read user messages even if compromised. Keys live only on user devices.

Typical implementation: - Key exchange: ECDH P-256 (one keypair per device). - Symmetric cipher: AES-256-GCM with a per-message random IV. - Pattern: every message body is encrypted client-side; server stores ciphertext only; recipients decrypt with their device key.

Used in: Not used in the portfolio — covered for comparison.

Tradeoffs. No server-side search, no message history when adding a new device without explicit re-share, push-notification previews must be empty or use a separate "preview key."


Field-level encryption (server-side)

What it is. Specific columns (PII, secrets, payment-method tokens) encrypted at rest beyond the disk-level encryption.

Used in: - GoGreen Verify — fieldCrypto with AWS KMS, PHI sealing / vault, rotateEncryptionKey, PII and secret redaction. - Recruiting AI — AES-256-GCM via FIELD_ENCRYPTION_KEY. - AI Concierge — FIELD_ENCRYPTION_KEY for webhook secrets. - SmartForms — Fernet-encrypted connector credentials. - Marketing AI — AES-encrypted OAuth tokens. - OpenSentinel — field-encryption, key-rotation and a memory vault. - GoGreen Seller AI — an encryption service. - DOC-AI — PHI vault, PII masking, BAA mode. - Sell Me A Pen — ENCRYPTION_KEY. - Go Green Transit desktop — OS keyring + aes-gcm.


Webhook signing and verification

Pattern. HMAC signature over the raw body; verify before processing.

Used in: Toolbelt Handyman and Workflow Hub (HMAC), OpenSentinel (with replay protection), AI Concierge and SmartForms (signed outbound webhooks), GGPI website (Stripe and Twilio signature verification; unsigned Stripe events are rejected in production), GameTrakker (Stripe), VotigoPro (verifyWebhook).


HTTP security headers (helmet / CSP)

Used in: Toolbelt Handyman (cspDirectives.ts), GoGreen Seller AI, APEX Sales Training, Recruiting AI, Tutor AI.


SSRF guards

Used in: Workflow Hub (MCP registry fetches) and DOC-AI (webhook_url_guard).


AI / agent safety

  • OpenSentinel — prompt-guard, tool sandbox, autonomy gating.
  • Recruiting AI — Piston code-execution sandbox and opossum circuit breakers.
  • GGPI website — the MCP server is staff-only and passes responses through stripSecrets.
  • Tutor AI — omni-moderation plus a safety.service.ts layer for a student audience, with COPPA (coppa.service.ts) and GDPR (gdpr.service.ts) services.
  • Jarvis (Tauri) — an autonomy gate decides which tool calls run without confirmation.

Licensing and non-custodial crypto

  • Ed25519 license signing — Go Green Transit.
  • Non-custodial crypto (public keys only on the server; it can derive addresses but cannot spend) — BidIt and the GGPI website (USDC on Base via an account-level xpub).

CAPTCHA / bot mitigation

Used in: GGPI website — reCAPTCHA v3 plus a honeypot on the public signup route. reCAPTCHA is intentionally not applied to login; login relies on the 10-per-15-minute rate limit. No other product surfaces a CAPTCHA in its config.


Secret management

See Infrastructure-Deployment.md. .env + New_API_Keys_and_Secrets_Master.md. No Vault / Secrets Manager.


Dependency scanning and SAST

Used in: DOC-AI (pip-audit gate, Trivy image scan, gitleaks, SHA-pinned actions), Toolbelt Handyman (gitleaks), GoGreen Seller AI (CodeQL). ESLint catches some security antipatterns elsewhere. No Snyk or Semgrep found.


SCIM 2.0

User/group provisioning from IdP. See Integrations-Comms.md. Used in: DOC-AI (SAML via pysaml2 plus SCIM). SmartForms has SAML SSO via python3-saml.


Audit logging

Pattern. Sensitive actions (admin changes, billing changes, role assignment) write a row to an audit_logs table with actor_id, action, target, metadata, ip, user_agent, at.

Used in: Sourcing AI (AuditLog), GGPI website (AuditLog and CRM audit log), Tutor AI (audit.service.ts), GameTrakker (lib/audit.ts plus an append-only ledger), Sell Me A Pen (AuditLog), Recruiting AI (audit service), AI Concierge (audit-log middleware), SmartForms, DOC-AI (audit_events), OpenSentinel (audit-logger and audit trail — core to its value prop), GoGreen Verify (read-audit and disclosure accounting).


Compliance / data residency

DOC-AI combines PHI handling, BAA mode, MFA, SAML, SCIM, IP allowlists and 90-day backups, aimed at compliance-conscious tenants. GoGreen Verify has a PHI mode (Bedrock), KMS-backed encryption, retention/purge and biometric consent. Recruiting AI has a SOC 2 readiness dashboard (91%, 21 of 23 controls) and a GDPR service. OpenSentinel has GDPR, data-retention and incident-response modules.

No product claims a formal SOC 2 / HIPAA / GDPR certification — the patterns are in place; certification would be a separate effort.


Comparison alternatives (not used)

Tool Notes
Vault, AWS Secrets Manager, Doppler Secrets management. .env + master file is intentional.
OPA / Cedar Policy-as-code. App-layer RBAC covers the use cases.
Snyk / Semgrep Vuln scanning. Not used; Trivy, CodeQL, gitleaks and pip-audit are (see above).
WAF (Cloudflare WAF, AWS WAF) Web app firewall. No WAF config in the repos.

Decision guide

Multi-tenant DB with strict isolation?     Application-layer tenant IDs on every row + an audit gate in CI
                                           (Toolbelt pattern); Postgres RLS if you need the DB to enforce it.
App-level RBAC?                            Role checks in middleware, or CASL (TS), Spatie (PHP).
Encrypt specific PII columns?              AES-256-GCM with a key in env (or KMS for PHI, as in GoGreen Verify).
Rate-limit endpoints?                      express-rate-limit / @fastify/rate-limit; Redis INCR + EXPIRE when shared.
Need SCIM provisioning?                    pysaml2 + SCIM endpoint exposure (DOC-AI).
Need audit logs?                           Append-only `audit_logs` table written by service-layer hooks.
Inbound webhooks?                          Verify the HMAC / provider signature on the raw body.