Understanding Security Requirements

What DoorFlow requires and why for physical access control in 5 minutes

5 mins
Beginner

DoorFlow has specific security requirements that may differ from consumer APIs you've used. This guide explains what you need to implement and why.

What DoorFlow Requires

1. OAuth Authorization (Always)

What it means

Your app must get explicit user permission via OAuth
Users authorize your app through DoorFlow's interface
You receive temporary access tokens, not permanent keys

What's NOT supported

API keys
Client credentials OAuth flow
Direct username/password authentication
Shared secrets for API access

Why: Every API request needs user context. DoorFlow needs to know which customer authorized your app and what they allowed you to do.

2. Refresh Tokens (Long-term Access)

What it means

Access tokens expire after 1 hour
You must implement token refresh to maintain access
Refresh tokens let you get new access tokens automatically

Why: Short-lived access tokens limit damage if credentials are compromised. If someone steals an access token, it only works for 1 hour.

What you need to build

Store refresh tokens securely (encrypted in database)
Detect when access token expires (401 response)
Automatically request new access token
Handle refresh failures (user revoked access)

See: [OAuth Token Refresh] guide

3. Signed Webhooks (For Event Notifications)

What it means

Webhook payloads include cryptographic signatures
Your app must verify signatures before processing events
Unsigned webhook requests should be rejected

Why: Webhooks control physical access decisions. Someone could fake webhook events to:

  • Claim a denied access attempt succeeded
  • Trigger false alarms
  • Manipulate audit logs

What you need to build

Verify webhook signatures using your client secret
Reject webhooks with invalid signatures
Handle signature verification failures

See: [Webhook Security] guide

4. Valid Refresh Token for Webhooks

What it means

Webhooks only sent to apps with active refresh tokens
If user revokes your app, webhooks stop immediately
No webhook notifications without valid authorization

Why: Webhooks contain sensitive information about building access. If a customer revokes your app, you shouldn't continue receiving their access events.

What this means for you: If webhooks stop arriving, check:

  • Has the customer revoked your app access?
  • Has your refresh token expired?
  • Do you need the customer to re-authorize?

What This Looks Like in Practice

Example: Visitor Management System

You're building an app that:

  • Registers visitors at reception
  • Creates temporary PINs for visitor access
  • Sends access codes via SMS
  • Logs visitor check-in/check-out times

Your security implementation:

sequenceDiagram participant Customer participant YourApp as Your App participant DoorFlow participant Building Note over Customer,Building: Initial Setup Customer->>YourApp: Signs up for your service YourApp->>Customer: "Authorize DoorFlow access" Customer->>DoorFlow: OAuth authorization flow DoorFlow->>YourApp: Access token + Refresh token YourApp->>YourApp: Store tokens (encrypted) Note over Customer,Building: Daily Operation YourApp->>DoorFlow: Create visitor
GET /api/3/people DoorFlow->>YourApp: Visitor created YourApp->>DoorFlow: Create PIN credential
POST /api/3/credentials DoorFlow->>YourApp: PIN generated: 5847 YourApp->>YourApp: Send PIN via SMS to visitor Note over Building: Visitor uses PIN at door DoorFlow->>YourApp: Webhook: access_granted event
(signed + verified) YourApp->>YourApp: Log visitor entry time Note over Customer,Building: Token Refresh (1 hour later) YourApp->>DoorFlow: API request DoorFlow->>YourApp: 401 Unauthorized YourApp->>YourApp: Detect expired token YourApp->>DoorFlow: POST /oauth/token
with refresh_token DoorFlow->>YourApp: New access + refresh tokens YourApp->>YourApp: Store new tokens YourApp->>DoorFlow: Retry API request DoorFlow->>YourApp: Success

Security Requirements Checklist

Use this to verify your integration meets DoorFlow's requirements:

OAuth Authorization

  • Implement Authorization Code OAuth flow
  • Handle user consent/authorization redirect
  • Exchange authorization code for tokens
  • Store access token and refresh token securely
  • Never expose tokens in logs or client-side code

Token Management

  • Encrypt refresh tokens in your database
  • Detect 401 Unauthorized responses
  • Automatically refresh expired access tokens
  • Handle refresh token failures gracefully
  • Prompt user to re-authorize if refresh fails

Webhook Security (if using webhooks)

  • Verify webhook signatures on every request
  • Reject webhooks with invalid signatures
  • Handle webhook signature verification failures
  • Monitor for stopped webhooks (may indicate revoked access)
  • Use HTTPS endpoint for receiving webhooks

General Security

  • Use HTTPS for all API calls (never HTTP)
  • Never log access tokens or refresh tokens
  • Implement proper error handling
  • Clear tokens when user disconnects your app
  • Follow OAuth best practices for your platform

Common Implementation Mistakes

1. Storing Tokens Insecurely

Wrong:

json
// Stored in plain text
{
  "access_token": "eyJhbGc...",
  "refresh_token": "def5020..."
}

Right:

json
// Refresh token encrypted
{
  "access_token": "eyJhbGc...",
  "refresh_token": "ENCRYPTED:U2FsdGVk..."
}

2. Not Handling Token Refresh

Wrong

Access token expires
All API calls fail
Integration breaks
User has to reconnect manually
Detect 401 response
Automatically use refresh token
Get new access token
Retry API call
Seamless experience

3. Ignoring Webhook Signatures

Wrong:

Receive webhook → Process immediately

Right:

Receive webhook → Verify signature → Reject if invalid → Process if valid

4. Logging Sensitive Data

Wrong:

javascript
console.log('API Response:', response);
// Logs: { access_token: "eyJhbGc...", refresh_token: "def5020..." }

Right:

javascript
console.log('API Response:', { status: response.status, id: response.data.id });
// Never log tokens

Why These Requirements Exist

Real-World Scenario: Compromised API Keys

What could happen without these protections

Attacker gets your API key (data breach, exposed in code, stolen laptop)

With API keys, attacker can:

  • Unlock any door in the system
  • Create credentials for anyone
  • Delete access for legitimate users
  • Monitor all building access events
  • No way to know it's not you
Unlock any door in the system
Create credentials for anyone
Delete access for legitimate users
Monitor all building access events
No way to know it's not you

With OAuth + short-lived tokens:

  • Stolen access token only works for 1 hour
  • Can't get new tokens without refresh token
  • Refresh token is encrypted in your database
  • Customer can revoke access immediately
  • Full audit trail shows which app did what
Stolen access token only works for 1 hour
Can't get new tokens without refresh token
Refresh token is encrypted in your database
Customer can revoke access immediately
Full audit trail shows which app did what

Real-World Scenario: Rogue Employee

Employee at your company goes rogue:

With API keys

Employee has access to shared API key
Can use it from anywhere
Can't be revoked without breaking production
No way to trace actions to specific employee

With OAuth

Each customer has separate authorization
Customer can revoke specific app access
Your logs show which employee's session did what
Can revoke employee access without affecting customers
Audit trail preserved

Getting Help

Implementation support

[What is OAuth and Why Use It?]
[OAuth Authorization Flow]
[OAuth Token Refresh]
[Webhook Security Guide]

Questions about why these requirements exist?

  • [Why Physical Access is Different]
  • [Why DoorFlow's Security is Non-Negotiable]

Testing: Use DoorFlow's OAuth demo environment - see [OAuth Application Demo]

Next Steps

Starting fresh?

  1. Read [What is OAuth and Why Use It?]
  2. Follow [Your First API Request]
  3. Implement [OAuth Token Refresh]
  4. Review the checklist above
  5. Test in demo environment

Have questions?

  • Check [Common Workflows] for real examples
  • Review [Error Handling] for edge cases
  • See [Why DoorFlow's Security is Non-Negotiable] for our philosophy