Docs/Security

Security Best Practices

Recommendations for keeping your Hygate workspace secure.


Overview

Hygate handles sensitive operations: access to physical spaces, payment processing, and team management. This guide covers security best practices across authentication, integrations, data protection, and operational procedures.


Authentication and Access Control

Passwords

RecommendationWhy
Minimum 16 charactersMakes brute force attacks impractical
Mix of upper/lower case, numbers, symbolsIncreases the search space
Use a password managerEnables unique, strong passwords for every account
Never reuse passwordsCompromised passwords are a common attack vector
Change passwords every 90 daysLimits the impact of undiscovered leaks

Two-Factor Authentication (2FA)

RecommendationWhy
Enable 2FA for all admin accountsProtects against credential theft
Use Authenticator App over Email OTPAuthenticator apps are phishing-resistant
Store backup codes securelyRequired for account recovery if 2FA device is lost
Don't use SMS-based 2FAHygate doesn't support SMS, which is correct — SMS 2FA is vulnerable to SIM swapping

Login Flow with 2FA

[1] LOGIN ATTEMPT
User enters email + password on login page
        │
        ▼
[2] CREDENTIAL VALIDATION
System validates email/password combination
        │
        ▼
[3] 2FA REQUIRED
If credentials valid → system generates 6-digit code
        │
        ▼
[4] EMAIL DISPATCH
Hygate → Resend API: send email
Email contains: 6-digit code, expiry time (5 minutes)
        │
        ▼
[5] USER RECEIVES EMAIL
User receives email with 2FA code
        │
        ▼
[6] CODE ENTRY
User enters code on 2FA screen
        │
        ▼
[7] CODE VALIDATION
System validates entered code
        │
        ▼
[8] SUCCESS PATH
Valid code: session created, redirected to dashboard
        │
        ▼
[9] FAILURE PATH
Invalid code: error shown
Code expires after 3 attempts or 5 minutes

Session Management

RecommendationWhy
Set reasonable session timeoutsReduces the window of opportunity after leaving a session open
Enable trust period (30 days)Balances security with convenience for trusted devices
Log out of shared devicesPrevents session hijacking on public computers
Monitor audit logs for suspicious loginsCatch unauthorized access early

Integration Credentials

API Key Management

IntegrationRotation FrequencyStorage
StripeEvery 90 daysEncrypted in database
TTLockEvery 90 daysEncrypted in database
ShellyEvery 90 daysEncrypted in database
ResendEvery 180 daysEncrypted in database

Credential Rotation Procedure

  1. Generate new keys in the provider's dashboard
  2. Enter new keys in Hygate Settings
  3. Test the integration connection
  4. Verify the old key no longer works
  5. Revoke the old key in the provider's dashboard
  6. Document the rotation in audit logs

Credential Storage

  • All integration credentials are encrypted at rest in the Hygate database using AES-256
  • Credentials are decrypted only at the point of use
  • Never store credentials in:
    • Version control (.env, settings.json)
    • Plain text files
    • Slack, email, or messaging apps
    • Shared spreadsheets

TTLock Security

RiskMitigation
Unauthorized lock controlTTLock credentials are encrypted; only admins can configure
Credential theftRotate credentials every 90 days
Guest impersonationQR access codes are single-use and time-limited
Passage mode misusePassage mode is logged in audit logs
Lock hackingTTLock uses standard encryption; keep lock firmware updated

Hardening TTLock

  • Use a dedicated TTLock account for the integration
  • Enable lock notifications in the TTLock app
  • Monitor audit logs for unexpected lock state changes
  • Regularly check battery levels in the TTLock app

Shelly Security

RiskMitigation
Unauthorized relay controlShelly auth keys are encrypted; only admins can configure
Relay hijackingShelly Cloud API requires authentication for all commands
Physical device accessShelly devices should be installed in tamper-resistant enclosures
Network exposureShelly devices should be on a separate VLAN if possible

Hardening Shelly

  • Use strong WiFi passwords for Shelly devices
  • Enable SSL/TLS for Shelly Cloud communication (enabled by default)
  • Place devices in locked enclosures
  • Monitor relay state changes in audit logs

Stripe Security

RiskMitigation
Payment fraudUse Stripe Radar (fraud detection)
Webhook spoofingHygate verifies Stripe's signature on every webhook
Key exposureSecret keys are encrypted; never share them
Refund abuseRefunds require Stripe Dashboard access; log all refund events

Stripe Best Practices

  • Enable Stripe Radar for automatic fraud detection
  • Set up Stripe Alerts for unusual activity
  • Monitor the Stripe Dashboard for suspicious transactions
  • Enable 3D Secure support — Hygate handles this automatically
  • Keep your Stripe account secure with 2FA and strong passwords

Webhook Security

ProtectionImplementation
Signature verificationHygate verifies Stripe's HMAC-SHA256 signature on every webhook
Replay preventionWebhook timestamps are validated to prevent old webhook replays
Secret storageWebhook secrets are encrypted in the database
HTTPS onlyHygate must be served over HTTPS for webhooks to work

Data Protection

Encryption

DataAt RestIn Transit
Integration credentialsAES-256 encryptedTLS 1.3
User passwordsbcrypt hashedTLS 1.3
Payment dataNot stored (delegated to Stripe)TLS 1.3
Audit logsEncryptedTLS 1.3
Session tokensJWT with signature verificationTLS 1.3
Guest emailsStored as plain textTLS 1.3

What Hygate Does NOT Store

  • Credit card numbers (handled entirely by Stripe)
  • TTLock account passwords (only MD5-hashed before OAuth)
  • Shelly device passwords (if any)

Operational Security

Access Control Principles

PrincipleDescription
Least privilegeAssign the Operator role by default; only admins get Administrator
Need to knowOperators only see what they need for operations
Separation of dutiesNo single person should control both integration settings and audit logs
Regular reviewQuarterly review of team access and role assignments

Audit Log Monitoring

Review your audit logs regularly for:

PatternWhat It May Indicate
Multiple failed loginsBrute force attack
Login from unusual locationAccount compromise
2FA method changedAccount takeover attempt
Integration credentials updatedCredential rotation or unauthorized change
Session force-endedEquipment issue or unusual activity
Bulk deletionsInsider threat or accidental action

Incident Response

IncidentResponse
Suspected account compromise1. Deactivate the account immediately 2. Reset all passwords 3. Review audit logs 4. Rotate all integration credentials
Suspected payment fraud1. Review Stripe Radar flags 2. Contact Stripe support 3. Review the payment record in Hygate
Unauthorized lock activation1. Check TTLock app for lock history 2. Review Hygate audit logs 3. Check for suspicious QR code placements
Data breach suspected1. Contact your hosting provider immediately 2. Preserve all logs 3. Assess scope 4. Notify affected parties

Infrastructure Security

Server Requirements

RequirementRecommendation
HTTPSMandatory — enables webhook verification
TLS versionTLS 1.3 minimum
FirewallBlock all ports except 80, 443, and SSH
SSH accessKey-based authentication only, no password SSH
UpdatesApply security patches within 7 days of release

Environment Variables

Never hardcode secrets in your application. Use environment variables:

# Required
DATABASE_URL=
ENCRYPTION_KEY=       # 32-byte key for encrypting credentials
STRIPE_SECRET_KEY=   # Use Stripe env var directly

# Optional overrides
TTLOCK_CLIENT_ID=
TTLOCK_CLIENT_SECRET=
SHELLY_AUTH_KEY=
RESEND_API_KEY=

Database Security

PracticeRecommendation
Access controlUse database roles with minimum necessary permissions
EncryptionEnable encryption at rest (provided by most cloud providers)
BackupsEnable automated backups with encryption
Connection poolingUse connection pooling to limit connections
SSLRequire SSL for all database connections

Compliance

GDPR Considerations (EU)

ConsiderationRecommendation
Guest emailsOnly collect if necessary; don't use for marketing
Right to erasureGuest data is pseudonymized in Hygate; Stripe data is managed through Stripe
Data retentionRetain payment records as required by financial regulations
Audit logsKeep audit logs for at least 2 years
EncryptionHygate encrypts all sensitive data at rest and in transit

PCI DSS (Payment Card Industry)

Hygate is not PCI DSS scope because:

  • Hygate never stores, processes, or transmits card numbers
  • Stripe handles all card data on their PCI-compliant infrastructure
  • Hygate only stores Stripe Payment Intent IDs

You remain responsible for:

  • Securing your Stripe account with strong credentials and 2FA
  • Monitoring for fraudulent transactions
  • Maintaining compliance with local payment regulations

Security Checklist

Initial Setup

  • Enabled 2FA (Authenticator App) for admin account
  • Stored backup codes in a password manager
  • Set a strong admin password (16+ characters)
  • Configured HTTPS on the server

Integrations

  • Configured Stripe with webhook signing secret
  • Set up TTLock integration
  • Set up Shelly integration
  • Configured email provider

Team

  • Invited operators with appropriate roles
  • Required 2FA for all users
  • Reviewed team access quarterly

Monitoring

  • Reviewed audit logs for the first week
  • Set up monitoring for failed payments
  • Reviewed integration health indicators daily

Maintenance

  • Set a calendar reminder to rotate credentials every 90 days
  • Set a calendar reminder for quarterly team access review
  • Reviewed security logs monthly