Set up the sidecar
Audience: engineers and platform teams deploying the sidecar for a member organisation. Before this page: your organisation has chosen its role (Provider, Requester, or both), holds a CamDX member code, and is registered in the Auth Portal. See Guide Part E, Phases 0 and 1. After this page: Integrate as a Requester or Integrate as a Provider.
By the end of this setup, you will have a running sidecar and backoffice, public keys published in DNS, CamDX services configured, an API key for your core system, and your partners allowlisted. A single sidecar supports both roles; your configuration and partner allowlist determine which role it plays with each partner.
Deployment architecture
| Endpoint group | Permitted callers | Authentication |
|---|---|---|
/api/v1/requester/* (including kyc/{ekyc_ref} and /status), /api/v1/provider/token/verify, /kyc/submit, /kyc/authorize, /kyc/invalidate | Your core system only | x-api-key and x-api-secret headers |
/api/v1/provider/kyc/resolve/t0–t3, /api/v1/provider/kyc/status, /api/v1/provider/kyc/ping | Your CamDX Security Server only | Token signature, Requester signature, and X-Road-Client member code |
/api/v1/admin/* | Sidecar backoffice and admin scripts | Admin JWT and role check |
/health | Monitoring | None |
/reference | Developers | None (restrict access in production) |
Never expose the sidecar to the public internet. Customers' browsers and mobile apps never call it directly.
Setup checklist
| Step | Task | Completion criteria |
|---|---|---|
| 1 | Create the keys | Signing key, attestation wallet, and PII key stored in your secret manager |
| 2 | Publish DNS records | dig TXT on your issuer domain returns both ekyc_pub= and openatts |
| 3 | Prepare PostgreSQL | Empty database created and owned by the sidecar DB user |
| 4 | Configure the sidecar | Environment file or Kubernetes Secret populated |
| 5 | Build and run | GET /health returns OK |
| 6 | Connect CamDX | Inbound services published; outbound calls reach your Security Server |
| 7 | Create an admin and an API key | Core system holds a valid keyId and secret |
| 8 | Allowlist your partners | Each partner is enabled and Ping succeeds |
Step 1: Create the keys
Three secrets are required. Generate production keys in a controlled environment and store them directly in your secret manager.
1a. Protocol signing key (ES512, curve P-521)
Signs every login token, auth token, and inter-sidecar request signature your sidecar issues. From the sidecar repository root:
node scripts/generate-test-resources.js
The script outputs three blocks:
---PRIVATE-PEM--- → value for JWT_PRIVATE_KEY (keep secret)
---PUBLIC-PEM--- → keep for reference
---DNS-RECORD--- → ekyc_pub=<base64>, publish this in DNS (step 2)
The DNS value is the base64-encoded compressed EC point required by the sidecar. If you generate the key with OpenSSL or an HSM, derive the compressed point using the same encoding.
1b. Attestation wallet
Signs the OpenAttestation documents issued by a Provider. It is an Ethereum-style encrypted JSON keystore whose address becomes your DID (did:ethr:<address>). Every member requires one because the sidecar loads it at startup. Generate it with the ethers v5 dependency included in apps/server:
cd apps/server
WALLET_PASS='<strong password>' node -e '
const { Wallet } = require("ethers");
const w = Wallet.createRandom();
w.encrypt(process.env.WALLET_PASS).then((json) => {
require("fs").writeFileSync("wallet.json", json, { mode: 0o600 });
console.log("address:", w.address);
});'
Record the printed address for your DNS configuration, and store wallet.json and WALLET_PASS in your secret manager. Never use the repository's docker/wallet.json test fixture outside local development.
1c. PII encryption key
The AES-256-GCM key used to encrypt cached KYC documents and image blobs. It must be exactly 32 UTF-8 bytes (32 ASCII characters), which the server validates at startup:
openssl rand -base64 48 | tr -dc 'A-Za-z0-9' | head -c 32; echo
Losing the attestation wallet prevents you from signing attestations under your DID. Losing PII_ENCRYPTION_KEY makes existing encrypted records unreadable. Store key backups separately from database backups.
Step 2: Publish DNS records
Publish two TXT records on your issuer domain (the value set in ISSUER, for example ekyc.yourorg.com.kh):
ekyc.yourorg.com.kh. 300 IN TXT "ekyc_pub=AgFx...base64..."
ekyc.yourorg.com.kh. 300 IN TXT "openatts a=dns-did; p=did:ethr:0xYourWalletAddress#controller"
| Record | Purpose | Notes |
|---|---|---|
ekyc_pub= | Used by partners and the Auth Portal to verify your tokens and request signatures | Accepts plain or URL-encoded base64. Values exceeding 255 characters can be split into multiple strings within a single TXT record; verifiers concatenate them. Publish multiple ekyc_pub= records during key rotation; verifiers try each in turn. |
openatts a=dns-did; p=… | Used by Requesters to verify that attestations are signed by your domain | The address in p= must match your attestation wallet address. |
Verify resolution from outside your internal network:
dig +short TXT ekyc.yourorg.com.kh
Enable DNSSEC on the zone to prevent record spoofing.
Step 3: Prepare PostgreSQL
- Provision PostgreSQL 15 or later inside your internal network with encrypted storage and backups.
- Create an empty database and assign ownership to the sidecar's database user.
- Database migrations run automatically on startup: do not run migrations manually. The server image bundles the migration files, applies any pending migrations at boot, and then ensures an initial admin account exists. If migration or admin bootstrap fails, the process exits.
Step 4: Configure the sidecar
The server validates all environment variables at startup and exits if any required variable is missing or malformed. See apps/server/.env.example in the sidecar repository for a template.
# Server
NODE_ENV=production
NODE_PORT=3000
SERVER_URL=https://sidecar.internal.yourorg.com.kh
CORS_ORIGIN=https://ekyc-admin.internal.yourorg.com.kh
LOG_LEVEL=info
# Database
DATABASE_HOST=pg.internal.yourorg.com.kh
DATABASE_PORT=5432
DATABASE_USER=ekyc_sidecar
DATABASE_PASSWORD=<secret>
DATABASE_NAME=ekyc_sidecar
# Identity
ISSUER=ekyc.yourorg.com.kh
ISS_CODE=YOURORG
JWT_PRIVATE_KEY="-----BEGIN EC PRIVATE KEY-----\nMIHc...\n-----END EC PRIVATE KEY-----\n"
REQUEST_TOKEN_EXPIRY_MINUTES=15
# CamDX
CAMDX_MEMBER_CODE=CAMBODIA/COM/<member>/<subsystem>
CAMDX_SECURITY_SERVER=https://camdx-ss.internal.yourorg.com.kh/r1
EKYC_AUTH_PORTAL_MEMBER_CODE=<Auth Portal member code, from registration>
# Attestations and encryption
WALLET_FILE_PATH=/run/secrets/wallet.json
WALLET_PASS=<secret>
PII_ENCRYPTION_KEY=<secret, exactly 32 characters>
# Backoffice
ADMIN_JWT_SECRET=<random secret, at least 32 bytes>
INITIAL_ADMIN_EMAIL=ekyc-admin@yourorg.com.kh
INITIAL_ADMIN_PASSWORD=<secret, required for first boot>
| Variable | Required | Value |
|---|---|---|
ISSUER | Yes | Your issuer domain where the DNS TXT records live. Appears as iss in every token you sign and as the DNS-DID location in attestations. |
ISS_CODE | Yes | Your partner code, matching what partners configure in their allowlists ([A-Z0-9_-]). Must match your member code in the Auth Portal registry, and ISSUER must match your registered issuer domain. |
JWT_PRIVATE_KEY | Yes | The PEM private key from step 1a. In a .env file, wrap it in double quotes with \n for line breaks. In Kubernetes, mount it from a Secret. |
CAMDX_MEMBER_CODE | Yes | Your CamDX member code, sent as X-Road-Client on outbound calls and matched by partners against their allowlists. |
CAMDX_SECURITY_SERVER | Yes | Base URL of your Security Server's REST interface. The sidecar appends the target member code and service path. |
EKYC_AUTH_PORTAL_MEMBER_CODE | Yes for Providers | The Auth Portal's CamDX member code. The Provider sidecar posts consent to {CAMDX_SECURITY_SERVER}/{EKYC_AUTH_PORTAL_MEMBER_CODE}/api/v1/provider/consent. |
WALLET_FILE_PATH, WALLET_PASS | Yes | Path to the keystore from step 1b (mounted read-only) and its password. |
PII_ENCRYPTION_KEY | Yes | The 32-byte key from step 1c. Never change this key while encrypted rows exist, or existing cached records will become unreadable. |
ADMIN_JWT_SECRET | Yes in production | Signs backoffice admin sessions. Must be explicitly set to at least 32 bytes when NODE_ENV=production. |
INITIAL_ADMIN_EMAIL, INITIAL_ADMIN_PASSWORD | First boot | Creates the initial super_admin when the admins table is empty. INITIAL_ADMIN_PASSWORD is required in all environments; INITIAL_ADMIN_EMAIL is required in production. |
API_KEY, API_SECRET | No | Optional static API key checked before database-managed keys. Leave both unset in production and use keys managed via the Admin API (step 7). |
ATTESTATION_STATUS_CHECKS | No | Providers only: status checks declared in new attestations (none [default], camdl, camdx, or camdl,camdx). See Optional status checks. |
DOCUMENT_STORE_ADDRESS, RPC_URL, CAMDL_CHAIN_ID | With camdl | Providers: your CamDL Document Store address, RPC URL, and chain ID for on-chain revocation. Requesters: RPC_URL and CAMDL_CHAIN_ID enable CamDL status checks. |
SENTRY_DSN and SENTRY_* | No | Optional error reporting via Sentry. |
See Environment variables for the complete list.
Optional status checks
Status checks let a Requester verify whether an attestation has been invalidated. They are optional and never block sharing. Leave ATTESTATION_STATUS_CHECKS unset (none) if you do not offer them.
# Provider, optional
ATTESTATION_STATUS_CHECKS=camdl,camdx
DOCUMENT_STORE_ADDRESS=0x<your Document Store on CamDL>
RPC_URL=https://<CamDL RPC>
CAMDL_CHAIN_ID=<CamDL chain ID>
# Requester, optional (to run CamDL checks)
RPC_URL=https://<CamDL RPC>
CAMDL_CHAIN_ID=<CamDL chain ID>
- With
camdl, you deploy and own an OpenAttestation Document Store on CamDL where your attestation wallet holds the revocation role. TSC, as CamDL chain owner, keeps Provider wallets funded. The server refuses to start ifDOCUMENT_STORE_ADDRESS,RPC_URL, orCAMDL_CHAIN_IDis missing or invalid. - With
camdx, publish thekyc-status-v1service on your Security Server in step 6. - Attestations do not expire; they remain valid until explicitly invalidated.
Step 5: Build and run
Build the container images from the sidecar repository, or pull published images from the CamDX registry (registry.camdx.gov.kh) provided by your network operator:
docker build -f docker/Dockerfile.server -t ekyc-sidecar:<version> .
docker build -f docker/Dockerfile.web -t ekyc-sidecar-web:<version> .
The server image runs Node.js 24 as a non-root user and listens on NODE_PORT (default 3000).
Docker Compose example (bound to internal interfaces only):
services:
sidecar:
image: ekyc-sidecar:<version>
env_file: sidecar.env
volumes:
- ./secrets/wallet.json:/run/secrets/wallet.json:ro
ports: ["127.0.0.1:3000:3000"]
restart: unless-stopped
backoffice:
image: ekyc-sidecar-web:<version>
environment:
- NEXT_PUBLIC_SERVER_URL=https://sidecar.internal.yourorg.com.kh
ports: ["127.0.0.1:3001:3000"]
restart: unless-stopped
Kubernetes: start from the manifests in the workspace deployment/ directory (Deployment, Service, ConfigMap, and Secret per role). Move all secret values out of ConfigMap into Secret. The server is stateless and supports running two or more replicas behind a Service. Because pending migrations run on startup, roll out one replica first when deploying a release with schema changes.
Verify the deployment:
curl -s https://sidecar.internal.yourorg.com.kh/health
# {"status":"OK","uptime":12.3,"timestamp":"2026-10-01T02:00:00.000Z"}
Confirm Database migrations applied appears in the startup logs. The interactive OpenAPI reference is served at /reference.
Step 6: Connect CamDX
All inter-member and Auth Portal traffic routes through CamDX Security Servers. Coordinate with your Security Server administrator to configure the following routes and permissions.
Outbound calls from your sidecar (via your Security Server):
| Purpose | Role | Target URL called by sidecar | Header |
|---|---|---|---|
| Redeem an auth token | Requester | {CAMDX_SECURITY_SERVER}/{provider CamDX member code}/resolve/t{tier} (POST) | X-Road-Client: {CAMDX_MEMBER_CODE} |
| Check attestation status via CamDX | Requester | {CAMDX_SECURITY_SERVER}/{provider CamDX member code}/{service} (POST) | X-Road-Client: {CAMDX_MEMBER_CODE} |
| Ping a partner from the backoffice | Either | {CAMDX_SECURITY_SERVER}/{partner CamDX member code}[/{camdx_ekyc_path}]/ping (GET) | X-Road-Client: {CAMDX_MEMBER_CODE} |
| Send consent and auth token to the Auth Portal | Provider | {CAMDX_SECURITY_SERVER}/{EKYC_AUTH_PORTAL_MEMBER_CODE}/api/v1/provider/consent (POST) | X-Road-Client: {CAMDX_MEMBER_CODE} |
Inbound services published by a Provider on its Security Server, forwarding to the sidecar:
| CamDX service path | Sidecar endpoint |
|---|---|
resolve/t0 | POST /api/v1/provider/kyc/resolve/t0 |
resolve/t1 | POST /api/v1/provider/kyc/resolve/t1 |
resolve/t2 | POST /api/v1/provider/kyc/resolve/t2 |
resolve/t3 | POST /api/v1/provider/kyc/resolve/t3 |
ping | GET /api/v1/provider/kyc/ping |
kyc-status-v1 (required if declaring camdx) | POST /api/v1/provider/kyc/status |
- Including the tier in the path allows CamDX to meter transactions per tier. Publish only the tiers you support.
- The sidecar identifies the calling member from the
X-Road-Clientheader; ensure the Security Server forwards this header unchanged. - Restrict access to these services to the CamDX member codes of allowlisted Requesters.
- Requesters call
kyc-status-v1at{CAMDX_SECURITY_SERVER}/{your member code}/kyc-status-v1. If you publish it under a different service code, setCAMDX_STATUS_SERVICE_CODEto match. - Requester-only organisations do not need to publish any inbound CamDX services.
Never use direct (non-CamDX) routing in production. Pointing CAMDX_SECURITY_SERVER at anything other than your Security Server bypasses CamDX mutual TLS, member authentication, and the exchange audit log.
Step 7: Create an admin and an API key
-
Sign in to the sidecar backoffice using
INITIAL_ADMIN_EMAILandINITIAL_ADMIN_PASSWORD. Change the initial password immediately, then create named accounts under Admin users with least-privilege roles:Role Permissions viewerRead dashboard, analytics, sessions, and attestation views editorViewer permissions, plus manage partners, run Ping, and retry failed CamDL publications adminEditor permissions, plus manage admin users, API keys, and read the activity log super_adminFull access, including updating and deleting admin accounts -
API keys for core systems are managed via the Admin API (
adminrole or higher). First obtain an admin JWT, then create a key:# Sign in as an admin or super_adminADMIN_TOKEN=$(curl -s -X POST "$SIDECAR_URL/api/v1/admin/auth/login" \-H "Content-Type: application/json" \-d '{"email":"ekyc-admin@yourorg.com.kh","password":"<your-password>"}' \| node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>console.log(JSON.parse(s).token))')# Create an API key for your core systemcurl -s -X POST "$SIDECAR_URL/api/v1/admin/api-keys" \-H "Authorization: Bearer $ADMIN_TOKEN" \-H "Content-Type: application/json" \-d '{"name":"core-banking-prod","expiresAt":"2027-10-01T00:00:00Z"}' -
The response returns a
keyId(prefixedsak_) and asecret. The secret is returned only once; the sidecar stores only its SHA-256 hash. Save both in your core system's secret store. -
Include both headers on every core-system call to the sidecar:
x-api-key: sak_3f9c...x-api-secret: 9b1e...
Issue a separate key per calling system and environment, set an expiry date, and revoke unused keys with DELETE /api/v1/admin/api-keys/{id}. Each key tracks its lastUsedAt timestamp via GET /api/v1/admin/api-keys.
Step 8: Allowlist your partners
Your sidecar communicates only with partners in its local allowlist. Both parties must configure each other: the Provider adds the Requester with the Requester role, and the Requester adds the Provider with the Provider role.
In the backoffice, open Partners → Add partner:
| Field | Value | How the sidecar uses it |
|---|---|---|
| Code | Partner's ISS_CODE, uppercase | Matched against iss_code and aud in tokens. On a Requester, enabled Provider codes populate the accept list in login tokens, determining which Providers the Auth Portal displays. |
| Name (EN / KH) | Display names | Shown in the backoffice and used by Providers on the consent screen. |
| CamDX member code | Partner's CamDX member code | Requester: target member for resolve and kyc-status-v1 calls. Provider: matched against X-Road-Client on incoming resolve, status, and ping calls. |
| CamDX eKYC path | Optional subpath on CamDX | Prepended before /ping when testing connectivity with Ping (leave blank if ping is published directly under the member code). |
| Roles | Provider if you fetch data from them; Requester if you share data to them; or both | Enforced on every token and CamDX call. |
| Max tier | Maximum tier permitted with this partner | Provider: login tokens requesting a higher tier are rejected. Defaults to 0, so configure this explicitly. |
| Domains | Partner's issuer domain(s) | Checked on both sides: Providers verify Requester login tokens, fetch signatures, and status queries against keys at these domains; Requesters verify Provider auth tokens, attestation DNS-DID locations, and status responses against them. |
New partners are created disabled by default. Click Enable, then Ping:
- Ping calls the partner's
/kyc/pingendpoint over CamDX. It returnspongonly when the partner has also added and enabled you with the Requester role and your exactCAMDX_MEMBER_CODE, making it the fastest end-to-end check of CamDX routing and mutual allowlist configuration. - Disable takes effect immediately, rejecting any new tokens, fetches, or resolve calls involving that partner.
Verify the setup
-
GET /healthreturns{"status":"OK",…}and startup logs confirmDatabase migrations applied. -
dig +short TXT <ISSUER>resolves bothekyc_pub=andopenattsrecords from outside your network. - You can sign in to the backoffice and have changed the initial admin password.
- Your core system holds an API key (
sak_…) and secret, and unauthenticated calls return401. - Every partner is enabled with the correct roles, domains, and max tier, and Ping succeeds for each Provider partner.
-
/reference,/api/v1/admin/*, and core-facing endpoints are inaccessible from the public internet.