Optare v1.0 is now available. Get started →
Architecture
Security Model

Security Model

Optare is built with security-first principles. This document explains our security architecture.

Defense in Depth

┌─────────────────────────────────────────────────────────────┐
│                      Network Layer                           │
│  • TLS 1.3 encryption  • DDoS protection  • WAF             │
├─────────────────────────────────────────────────────────────┤
│                    Application Layer                         │
│  • Input validation  • CSRF protection  • Rate limiting     │
├─────────────────────────────────────────────────────────────┤
│                   Authentication Layer                       │
│  • PKCE  • MFA  • Secure password hashing  • Token rotation │
├─────────────────────────────────────────────────────────────┤
│                   Authorization Layer                        │
│  • RBAC  • Org isolation  • Scope-based access              │
├─────────────────────────────────────────────────────────────┤
│                      Data Layer                              │
│  • Encryption at rest  • Audit logs  • Backup encryption    │
└─────────────────────────────────────────────────────────────┘

Authentication Security

Password Security

MeasureImplementation
HashingArgon2id with unique salts
Minimum Length12 characters (configurable)
Breach DetectionCheck against HaveIBeenPwned
Rate Limiting5 failed attempts = 15 min lockout

Token Security

TokenSecurity Measures
Access TokenShort-lived (1hr), signed with RS256
Refresh TokenRotated on use, revocable
ID TokenSigned, audience-restricted

PKCE (Proof Key for Code Exchange)

All Authorization Code flows use PKCE to prevent code interception:

1. Client generates random code_verifier
2. Client creates code_challenge = SHA256(code_verifier)
3. Authorization request includes code_challenge
4. Token request includes code_verifier
5. Server verifies SHA256(code_verifier) == code_challenge

Authorization Security

Role-Based Access Control (RBAC)

Permission = Organization + Role + Action

Can user delete members?
├── User belongs to Org A? ✓
├── User role is Admin? ✓
├── Admin can delete members? ✓
└── Result: ALLOWED

Tenant Isolation

Every data access is scoped by organization:

// All queries include organizationId
const data = await db.query({
  where: {
    organizationId: req.user.organizationId, // REQUIRED
    ...otherFilters
  }
});

API Security

MeasureDescription
Token ValidationVerify signature, issuer, audience, expiration
Scope CheckingEnsure token has required scopes
Rate LimitingPer-user and per-org limits
Input ValidationZod schemas for all inputs

Data Security

Encryption

TypeImplementation
In TransitTLS 1.3 (minimum TLS 1.2)
At RestAES-256 for sensitive fields
BackupsEncrypted with separate keys

Sensitive Data Handling

// Passwords never logged or returned
const user = await getUser(id);
delete user.passwordHash; // Never expose
 
// Tokens masked in logs
logger.info('Token issued', { 
  token: `${token.slice(0, 8)}...` 
});

Audit Logging

All security-relevant events are logged:

EventLogged Data
Login SuccessUser, IP, timestamp, method
Login FailureEmail attempt, IP, timestamp
Permission DeniedUser, resource, action
Token RevokedToken ID, reason, admin
Settings ChangedBefore/after, admin, timestamp

Infrastructure Security

Hosting

AspectImplementation
ProviderCloudflare / Vercel / Fly.io
RegionsUser-selectable
IsolationContainer-based isolation
SecretsEnvironment variables, encrypted

Network

  • DDoS Protection - Cloudflare at edge
  • WAF - OWASP rule sets
  • IP Allowlisting - Enterprise feature

Secrets Management

Environment Variables (encrypted)
├── DATABASE_URL
├── JWT_SECRET
├── ENCRYPTION_KEY
└── THIRD_PARTY_SECRETS

Compliance

Standards

StandardStatus
GDPRCompliant
SOC 2In progress
HIPAAAvailable on request
ISO 27001Planned

Data Residency

Choose where your data is stored:

  • US - us-east-1
  • EU - eu-west-1
  • APAC - ap-southeast-1

Data Retention

Data TypeRetention
Active user dataUntil deletion
Audit logs90 days (1 year enterprise)
Deleted accounts30 days (recovery period)
Backups30 days

Security Checklist for Your App

  • Validate tokens on every API request
  • Check iss, aud, and exp claims
  • Scope all database queries by organizationId
  • Use RBAC for sensitive operations
  • Enable MFA for admin users
  • Log security events
  • Set up monitoring/alerting

Next Steps