Skip to content

Integration Security

Document ID: ACP-001.5 Version: 1.0 Classification: Internal / Regulator-Shareable Effective Date: March 2026 Next Review: September 2026 Parent Document: ACP-001 — Access Control & Permissions


1. Overview

Keshless provides secure API integration capabilities for third-party systems (POS systems, payment gateways, partner platforms) through vendor-specific API keys. This document covers API key lifecycle management, IP whitelisting, access scoping, and security controls for external integrations.

2. Integration Architecture

┌────────────────────────┐
│   Partner System       │
│   (e.g., POS, ERP)    │
└──────────┬─────────────┘

           │  X-API-Key: <vendor_api_key>
           │  From whitelisted IP


┌──────────────────────────────────────────┐
│          API Gateway (Cloud Run)          │
│                                          │
│  ┌────────────────────────────────────┐  │
│  │  validateVendorApiKey() middleware  │  │
│  │                                    │  │
│  │  1. Extract X-API-Key header       │  │
│  │  2. Look up key in database        │  │
│  │  3. Check key not expired          │  │
│  │  4. Validate IP against whitelist  │  │
│  │  5. Attach vendor + integration    │  │
│  │     info to request                │  │
│  └────────────────────────────────────┘  │
│                                          │
│  Request proceeds with vendor context    │
│  (scoped to the vendor that owns the key)│
└──────────────────────────────────────────┘

3. API Key Lifecycle

3.1 Key Creation

StepDetail
WhoVendor owner (JWT authenticated) or system admin
EndpointPOST /api/integrations
AuthenticationJWT Bearer token required
AuthorizationVendor ownership check (must own the vendor account)
OutputAPI key string + integration record ID

Integration Record Fields:

FieldDescription
idUnique integration ID
vendorIdOwning vendor
apiKeyThe generated key (hashed for storage)
appNamePartner application name (e.g., "parkmate", "custom")
ipWhitelistArray of allowed IP addresses (optional)
expiresAtKey expiration date (optional)
statusACTIVE, REVOKED, or EXPIRED
lastUsedAtLast successful use timestamp
requestCountTotal API calls made with this key
createdAtCreation timestamp

3.2 Key Rotation

StepDetail
EndpointPATCH /api/integrations/{id}/rotate
AuthenticationJWT Bearer token
EffectOld key invalidated, new key generated
DowntimeInstant — old key stops working immediately

3.3 Key Revocation

StepDetail
EndpointDELETE /api/integrations/{id}
AuthenticationJWT Bearer token
EffectKey status set to REVOKED; all subsequent requests rejected

3.4 Key Listing

StepDetail
EndpointGET /api/integrations?vendorId=X
AuthenticationJWT Bearer token
ScopeOnly shows keys for the authenticated vendor (or all if admin)

4. Validation Process

When a request arrives with an X-API-Key header, the validateVendorApiKey() middleware performs these checks in order:

4.1 Validation Steps

StepCheckFailure Response
1Header present401 — API key required
2Key exists in database401 — Invalid API key
3Key status is ACTIVE401 — API key revoked or inactive
4Key not expired (expiresAt)401 — API key expired
5IP whitelist check (if configured)403 — IP address not authorized
6Attach vendor + integration to request— (proceeds)

4.2 IP Whitelist

If the integration has an ipWhitelist configured:

  • Request IP checked against x-forwarded-for header first, then req.ip
  • Supports individual IP addresses
  • If no whitelist is configured, all IPs are accepted
  • Empty whitelist = no restriction (opt-in security)

4.3 Post-Validation

After successful validation, the middleware attaches:

FieldAttached ToDescription
req.vendorRequest objectFull vendor record
req.integrationRequest objectIntegration record (key metadata)

All subsequent middleware and controllers can use req.vendor to scope operations to the authenticated vendor.

5. Access Scoping

5.1 Vendor Isolation

Integration API keys are scoped to a single vendor. All operations performed through an API key are restricted to:

  • The vendor's own transactions
  • The vendor's own customers
  • The vendor's own financial data

An integration API key cannot:

  • Access other vendors' data
  • Perform admin operations
  • Modify the vendor's own API keys (must use JWT auth for that)
  • Access system configuration

5.2 Operation Scope

Integration API access is limited to vendor-facing operations:

Allowed OperationsNot Allowed
Process paymentsAdmin dashboard access
View transaction historyUser management
Check vendor balanceSystem configuration
Customer operationsAML/compliance operations
Emergency control management
Other vendors' data

6. Security Controls

6.1 Key Storage

AspectImplementation
Storage formatSHA-256 hashed in database
DisplayFull key shown only at creation; never retrievable again
RotationOld key immediately invalidated on rotation

6.2 Monitoring

MetricTracked
lastUsedAtUpdated on every successful API call
requestCountIncremented on every successful API call
Audit logKey creation, rotation, and revocation logged

6.3 Best Practices for Partners

PracticeRecommendation
Key storageStore in environment variables or secret manager; never in source code
IP whitelistingConfigure allowed IPs for production integrations
Key rotationRotate keys at least every 90 days
ExpirationSet expiration dates on keys; request new keys before expiry
MonitoringMonitor requestCount for unusual spikes
HTTPS onlyAll API calls must use HTTPS (enforced by Cloud Run)

7. Application API Key

7.1 Purpose

Separate from vendor integration keys, the application API key (APP_API_KEY) is a shared secret used by Keshless frontend applications:

AspectDetail
HeaderX-API-Key
ValidationvalidateApiKey() middleware
ScopePublic-facing endpoints requiring basic authentication
StorageEnvironment variable on server

7.2 Dual Authentication

Some endpoints accept either JWT Bearer token OR application API key via the validateBearerOrApiKey() middleware. This allows:

  • Authenticated users to access with their JWT (full context)
  • Frontend apps to access with the shared API key (limited context)

8. Job/Scheduler Authentication

8.1 Purpose

Automated jobs (Cloud Scheduler triggers) authenticate separately from users and integrations:

AspectDetail
HeaderX-Job-Secret
ValidationvalidateJobSecret() middleware
SecretJOB_SECRET environment variable
ScopeBackup jobs, reconciliation, scheduled maintenance
User contextNone — operates as system

8.2 Protected Job Endpoints

Job authentication is applied to scheduled task endpoints only:

  • Database backup triggers
  • Reconciliation jobs
  • Cleanup and maintenance tasks

These endpoints are not accessible via JWT or API key authentication — they exclusively require the job secret.

9. Third-Party Service Access

9.1 Outbound Integrations

Keshless connects to external services with the following access controls:

ServiceAuthenticationPurpose
Notification ServiceAPI Key (X-API-KEY header)SMS/WhatsApp OTP delivery
GCP Cloud StorageService account credentialsKYC document storage
GCP Cloud SQLCloud SQL Proxy + IAMDatabase access
GCP Secret ManagerService account credentialsSecret retrieval

9.2 Notification Service

The shared notification service at notifications.eneza.app is authenticated via a dedicated API key:

AspectDetail
HeaderX-API-KEY
ChannelsWhatsApp (primary), SMS (fallback)
Used forOTP delivery, authentication codes
AccessServer-to-server only (never exposed to clients)

Internal use only - Keshless Payment Platform