Authentication
Authentication GuideΒΆ
This document outlines the authentication and session management strategy for the real-time voice agent application that integrates Azure Communication Services (ACS) with external telephony systems.
Table of ContentsΒΆ
- Architecture Overview
- Authentication Flow Diagram
- Call Flow Types
- PSTN Flow (with DTMF Authentication)
- SIP Flow (with DTMF Authentication)
- API Flow (with Direct Lookup)
- WebSocket Authentication
- Session Key Management
- Security Architecture
- Technical References
Architecture OverviewΒΆ
The system uses Azure Communication Services Call Automation as the unified media processing layer with three distinct authentication mechanisms:
- π DTMF Authentication: For PSTN and SIP calls using media tone analysis
- π Direct Lookup: For API calls using call connection IDs
- π¦ Redis Session Store: Centralized session management across all flows
Key ComponentsΒΆ
- Event Grid Integration: Delivers
IncomingCallevents with webhook callbacks - Call Automation REST API: Asynchronous interface for call control
- Session Border Controllers (SBCs): Certified SBCs for Direct Routing
- WebSocket Security: Custom token validation for real-time media
- AWS Connect Integration: Cross-cloud session handoff using Resume Contact API
Authentication Flow DiagramΒΆ
Call Flow TypesΒΆ
PSTN FlowΒΆ
Authentication Method: DTMF Media Analysis
- Call Setup: Caller β AWS Connect IVR β SBC β ACS PSTN
- Session Storage: AWS Connect stores
pstn:ani:codein Redis - Authentication: DTMF analysis extracts caller ANI and codes
- Validation: System checks Redis for matching composite key
- Authorization: Valid sessions proceed to WebSocket handler
SIP FlowΒΆ
Authentication Method: DTMF Media Analysis
- Call Setup: SIP Client β Enterprise SBC β ACS SIP Interface
- Session Storage: SBC stores
sip:call_idin Redis - Authentication: DTMF analysis extracts SIP call identifier
- Validation: System validates against stored session key
- Authorization: Authenticated calls establish media streaming
API FlowΒΆ
Authentication Method: Direct Call Connection ID Lookup
- Call Setup: Client β
/api/callendpoint β ACS Call Automation - Session Storage: API stores
acs:call_connection_idin Redis - Authentication: Direct lookup using known call connection ID
- Validation: No DTMF analysis required
- Authorization: WebSocket established with validated session
WebSocket AuthenticationΒΆ
WebSocket connections require secure authentication for real-time media processing. The system implements custom token validation based on the established session.
WebSocket Security ImplementationΒΆ
For detailed WebSocket authentication patterns, see the official Azure Communication Services documentation: Secure Webhook Endpoint
Key Security FeaturesΒΆ
- Token-based Authentication: Custom JWT tokens for WebSocket connections
- Session Correlation: WebSocket sessions correlated with call sessions
- Real-time Validation: Continuous validation during media streaming
- Secure Handshake: Encrypted WebSocket handshake process
Session Key ManagementΒΆ
Session Key FormatsΒΆ
| Flow Type | Key Format | Example | Purpose |
|---|---|---|---|
| PSTN | pstn:ani:code |
pstn:+15551234567:823 |
ANI + DTMF code from AWS Connect |
| SIP | sip:call_id |
sip:abc-xyz-123 |
Call identifier from enterprise SBC |
| API | acs:call_connection_id |
acs:call_connection_id:abc123 |
Direct call connection ID |
Authentication ProcessΒΆ
For PSTN/SIP Calls (DTMF-based):
1. External system stores session key in Redis
2. ACS receives IncomingCall event
3. System analyzes DTMF media stream
4. Extracts caller data and constructs composite key
5. Validates key existence in Redis
6. Authorizes or rejects WebSocket connection
For API Calls (Direct lookup):
1. Client calls /api/call endpoint
2. System stores call connection ID in Redis
3. ACS establishes call and triggers event
4. Direct lookup using call connection ID
5. Authorizes WebSocket connection
Security ArchitectureΒΆ
π DTMF-Based Authentication LogicΒΆ
The authentication flow leverages DTMF media analysis for telephony calls (PSTN/SIP) and direct call connection ID lookup for API-initiated calls to bridge session context between cloud platforms:
- Session Pre-Storage: External systems (AWS Connect, SBC) store composite keys in Redis; API calls store call connection IDs
- EventGrid Delivery:
IncomingCallevents trigger authentication processing - Authentication Method:
- DTMF Analysis: For PSTN/SIP calls - extracts caller information and DTMF codes from media stream
- Direct Lookup: For API calls - uses call connection ID from the initial
/api/callrequest - Composite Key Construction: Builds Redis lookup key using extracted data or call connection ID
- Redis Validation: Checks if composite key exists in session store
- Authentication Decision: Key presence determines authorization success/failure
- WebSocket Authorization: Only validated sessions proceed to real-time media processing
Authentication StatesΒΆ
- β Valid Session:
- PSTN/SIP: Composite key exists in Redis β DTMF authentication successful β WebSocket authorized
- API: Call connection ID exists in Redis β Direct lookup successful β WebSocket authorized
- β³ Processing Authentication:
- PSTN/SIP: DTMF media analysis in progress β Authentication pending
- API: Call connection ID lookup in progress β Authentication pending
- β Invalid Session:
- PSTN/SIP: Composite key missing or DTMF analysis failed β Authentication failed β Connection rejected
- API: Call connection ID missing or invalid β Authentication failed β Connection rejected
Fallback MechanismsΒΆ
- DTMF Re-analysis: If initial DTMF extraction fails for PSTN/SIP calls, system can re-analyze media stream
- Session Recovery: Temporary authentication failures can be retried with configurable timeout
- API Call Validation: For API calls, validates against the original
/api/callrequest session - Key Expiration: Redis keys have configurable TTL to prevent stale session accumulation
π Security LayersΒΆ
| Layer | Method | Purpose |
|---|---|---|
| Event Grid | Azure Event Grid Security | Secure IncomingCall event delivery |
| DTMF Analysis | Media Stream Processing | Extract caller data for authentication |
| Redis Validation | Composite Key Lookup | Primary authorization decision |
| WebSocket | Custom JWT + Session Auth | Real-time media stream security |
| API Endpoints | EasyAuth (Microsoft Entra ID) | HTTP endpoint protection |
Security ImplementationΒΆ
- Media Stream Security: DTMF analysis on encrypted ACS streams
- Session Timeout: Configurable TTL (default: 1 hour)
- Rate Limiting: DTMF processing abuse prevention
- Key Cryptography: Secure Redis key formatting
- Cross-Cloud Validation: Secure AWS Connect β ACS handoff
Technical ReferencesΒΆ
Azure Communication ServicesΒΆ
- Call Automation Overview
- Incoming Call Events
- Direct Routing SIP Specification
- Secure Webhook Endpoints